OpenEdge Data Management: DataServer for Microsoft SQL Server
OpenEdge Data Management: DataServer for Microsoft SQL Server
OpenEdge Data Management: DataServer for Microsoft SQL Server
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 2: Initial Programming Considerations<br />
Record creation<br />
Record creation is handled differently <strong>for</strong> <strong>OpenEdge</strong> databases and MS <strong>SQL</strong> <strong>Server</strong><br />
data sources accessed through the <strong>Data</strong><strong>Server</strong>. The difference occurs because ABL<br />
code run against an <strong>OpenEdge</strong> database follows different record-scoping rules than<br />
ABL code run against a MS <strong>SQL</strong> <strong>Server</strong> data source.<br />
Records are scoped to the outermost block in which they are used, or the smallest<br />
enclosing block that encompasses all references to a record. In the absence of<br />
enclosing blocks, a record is scoped to the procedure block. Outside of record scope,<br />
a buffer associated with a record is cleared by ABL.<br />
The <strong>OpenEdge</strong> database writes a record to the database after all its indexed columns<br />
are assigned. The MS <strong>SQL</strong> <strong>Server</strong> <strong>Data</strong><strong>Server</strong> writes records or record changes out to<br />
the database at the end of record scope or at the end of a transaction boundary within<br />
that record scope. For this reason, the duration of record locks can vary between<br />
<strong>OpenEdge</strong> and a MS <strong>SQL</strong> <strong>Server</strong> data source since the record lock will be held from<br />
the time of the write until the end of a transaction.<br />
While both <strong>OpenEdge</strong> and MS <strong>SQL</strong> <strong>Server</strong> data sources both commit changes at a<br />
transaction boundary, <strong>OpenEdge</strong> is capable of downgrading the lock on a record within<br />
scope after a commit boundary has been traversed. A MS <strong>SQL</strong> <strong>Server</strong> data source<br />
drops all record locks at the end of a transaction. See the “Transaction scoping and<br />
buffer management” section on page 100 <strong>for</strong> more in<strong>for</strong>mation.<br />
The following ABL statements will <strong>for</strong>ce a physical database write to a MS <strong>SQL</strong> <strong>Server</strong><br />
data source be<strong>for</strong>e the end of a transaction block or the end of record scope:<br />
• RELEASE<br />
• VALIDATE<br />
• RECID/ROWID<br />
While these statements can change lock status and <strong>for</strong>ce a write, they have no affect<br />
on transaction scope. Locks will be held from the time of the write until the time of a<br />
commit or rollback. For the RELEASE statement, the record is released from its buffer<br />
but is inaccessible and still locked awaiting a transaction boundary. After a RELEASE, a<br />
record would need to be reread in order to refill buffer content. The <strong>OpenEdge</strong><br />
database waits <strong>for</strong> all the key values to be assigned or <strong>for</strong> the end of record scope to<br />
write a record regardless of the outcome of a VALIDATE statement. The MS <strong>SQL</strong> <strong>Server</strong><br />
<strong>Data</strong><strong>Server</strong> writes a record at the time of the VALIDATE since a write is required in order<br />
to resolve the integrity of a record within the MS <strong>SQL</strong> <strong>Server</strong> data source. <strong>OpenEdge</strong><br />
can assign a RECID or ROWID without writing a record. For a MS <strong>SQL</strong> <strong>Server</strong> data<br />
source, the generation of RECID and ROWID are contingent on a record write in order to<br />
produce its value.<br />
The availability of database changes is dependent on when the record is written. The<br />
user writing the record can read back the in-memory copy of the record as soon as it<br />
has been written out to the database. Another user trying to access the same record<br />
may or may not see the changes written to the database, depending on the transaction<br />
isolation level of the <strong>for</strong>eign data source. While <strong>OpenEdge</strong> will show other users<br />
records modified but not yet committed, a MS <strong>SQL</strong> <strong>Server</strong> data source will not report<br />
on the state of record content until a transaction boundary has been traversed.<br />
There<strong>for</strong>e, while <strong>OpenEdge</strong> might indicate that a record already exists or has certain<br />
content be<strong>for</strong>e another user has committed such changes, a MS <strong>SQL</strong> <strong>Server</strong> data<br />
source will report that the record is in use and block access until the transaction is<br />
complete. The code fragments in this section illustrate these differences.<br />
90 <strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong>