13.01.2013 Views

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Data</strong> source record locking<br />

to be lost because the procedure applies updates based on the first find of the record, and these<br />

updates will overwrite the values from the second find of the record.<br />

Using the <strong>Data</strong><strong>Server</strong> to access a MS <strong>SQL</strong> <strong>Server</strong> database ensures that locks are upgraded in<br />

the data source in the same way as in an <strong>OpenEdge</strong> database. For example, the following<br />

procedure causes the same behavior whether you access an <strong>OpenEdge</strong> database or a MS <strong>SQL</strong><br />

<strong>Server</strong> data source:<br />

FIND customer WHERE customer.custnum EQ 10.<br />

DISPLAY customer.<br />

PROMPT-FOR customer.<br />

DO TRANSACTION:<br />

ASSIGN customer.<br />

END.<br />

The record is share-locked when it is fetched. The <strong>Data</strong><strong>Server</strong> upgrades the share lock to an<br />

exclusive lock inside the transaction by locking the record, reading it, and checking whether the<br />

record has changed since it was first fetched. If it has changed, the lock upgrade fails and you<br />

receive an error message.<br />

You might have to wait to access a record under the following circumstances:<br />

• You try to update a record when another user is reading it (it is share-locked). This also<br />

depends on the isolation level.<br />

• You try to read or update a record when another user is updating it (it is exclusive-locked).<br />

When this happens, <strong>OpenEdge</strong> uses a time-out loop, checking periodically to see whether the<br />

record is available. You can choose Cancel at any time to abort the request.<br />

The MS <strong>SQL</strong> <strong>Server</strong> data source notifies the <strong>Data</strong><strong>Server</strong> if it cannot per<strong>for</strong>m a requested<br />

operation within a given period of time. Under unusual system or network loads, the <strong>Data</strong><strong>Server</strong><br />

might receive notification that a request has not been completed. In this case, it returns a<br />

message that the record the request was accessing is locked, even though no other user has a<br />

lock on the record.<br />

One type of locking behavior that you might encounter is a deadlock, or “deadly embrace.” A<br />

deadlock occurs when two users want to access each other’s table, page, or record, and the table,<br />

page, or record that they want either has an exclusive lock on it, or one of the users needs to put<br />

an exclusive lock on it. Neither table, page, or record will give up its lock until the other table,<br />

page, or record is available. When a MS <strong>SQL</strong> <strong>Server</strong> data source detects this situation:<br />

• The data source kills the transaction that has accumulated the least amount of CPU time<br />

and releases the table, page, or record <strong>for</strong> the other user.<br />

• The ABL displays a message that the transaction was killed.<br />

• The system responds as if you had chosen Cancel.<br />

For details on how <strong>OpenEdge</strong> database locks work, see <strong>OpenEdge</strong> Getting Started: ABL<br />

Essentials. See ODBC and MS <strong>SQL</strong> <strong>Server</strong> documentation <strong>for</strong> more in<strong>for</strong>mation about locks in<br />

MS <strong>SQL</strong> <strong>Server</strong>.<br />

2–41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!