skip to main content
OpenEdge Data Management: DataServer for ODBC
Programming Considerations : Data-source record locking : Share locks
 

Share locks

ODBC defines four isolation levels in the following order from least to most restrictive: read uncommitted, read committed, repeatable read, and serializable. These isolation levels will determine what kind of share locks will take effect against a given data source. Not all data sources support all levels.
ODBC data sources do not respond to the SHARE-LOCK option in the ABL FOR EACH and FIND statements. Instead, share locks are governed by the data source and the available ODBC isolation levels allowed by that data source. A SHARE-LOCK specification does affect how the ODBC DataServer accesses records however. For greatest DataServer efficiency, it is always recommended that the NO-LOCK option be specified in your ABL if you do not need to lock records for update. Record isolation will still be managed by the data source irrespective of the lock mode chosen. If you wish to change the share lock behavior of your data source, you may be able to do so by changing the isolation level at connection time using the –Dsrv parameter TXN_ISOLATION.
When you read records with a FOR EACH or FIND statement, regardless of whether you include the SHARE–LOCK option, the ODBC data source typically behaves as follows:
*It puts some form of shared lock on the record, page, or table if the ODBC isolation level is anything other than read uncommitted. This occurs regardless of whether the share lock is specified in the ABL statement.
*After the data source reads the record, it releases the shared lock if the isolation level is read uncommitted or read committed. It may hold share locks until the completion of a transaction if the isolation level is repeatable read or serializable.
If a record has a shared lock on it, other users can usually access that record and apply a shared lock, but this is dependent on the isolation level and DataServer locking behavior. Refer to the transaction and locking references in the Microsoft ODBC Programmer's Reference or data source reference manuals for more information.