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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Transactions<br />

Transactions<br />

With <strong>Data</strong><strong>Server</strong> operations, a MS <strong>SQL</strong> <strong>Server</strong> data source handles its own transaction roll back<br />

and recovery operations. However, the <strong>OpenEdge</strong> transaction scoping rules apply: a transaction<br />

ends when the code exits the outermost block that per<strong>for</strong>ms an update. With the <strong>Data</strong><strong>Server</strong>,<br />

ABL per<strong>for</strong>ms as follows:<br />

• Sends a COMMIT to the data source, when a transaction that updates a MS <strong>SQL</strong> <strong>Server</strong> data<br />

source ends successfully.c<br />

• Sends a ROLLBACK to the data source if you interrupt the transaction.<br />

See <strong>OpenEdge</strong> Getting Started: ABL Essentials <strong>for</strong> details on how ABL handles transactions<br />

and error conditions.<br />

Transaction scoping and buffer management<br />

The <strong>Data</strong><strong>Server</strong> and an <strong>OpenEdge</strong> database hold locks differently at transaction boundaries. The<br />

<strong>OpenEdge</strong> database will hold a lock past the transaction boundary where the <strong>Data</strong><strong>Server</strong> will<br />

not. This causes different behavior in the use of buffers. Consider the following example:<br />

DEFINE BUFFER st_buf1 FOR state.<br />

DEFINE BUFFER st_buf2 FOR state.<br />

DO TRANSACTION: /* Transaction 1 */<br />

FIND st_buf1 WHERE st_buf1.state EQ "NH" EXCLUSIVE-LOCK.<br />

DISPLAY st_buf1.state-name. /* state-name = "New Hampshire" */<br />

END.<br />

/* During this pause, state-name is changed from "New Hampshire" to "Granite<br />

State" by an external user */<br />

PAUSE MESSAGE " state.state-name ".<br />

DO TRANSACTION: /* Transaction 2 */<br />

FIND st_buf2 WHERE st_buf2.state EQ "NH" EXCLUSIVE-LOCK.<br />

DISPLAY st_buf1.state-name st_buf2.state-name.<br />

END.<br />

Executing the above code against an <strong>OpenEdge</strong> database will downgrade the EXCLUSIVE-LOCK<br />

in Transaction 1 to a SHARE-LOCK. This occurs at the end of Transaction 1 and remains in effect<br />

at the time of the PAUSE statement and prior to the start of Transaction 2. This SHARE-LOCK<br />

prevents another user from modifying the state-name value between the transactions. As an<br />

optimization, when Transaction 2 is executed, the client does not refresh the st_buf1 buffer<br />

since the SHARE-LOCK prevented its contents from becoming stale between transactions. Also,<br />

since st_buf2 will have the same data integrity as st_buf1, they share the same buffer content.<br />

2–43

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

Saved successfully!

Ooh no, something went wrong!