DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Row-Level Locking in MSSQL 7


I have a hard time trying to make my application acquire one of those neat row-level locks that were introduced in MSSQL 7. How do I do this?


Row-level locking is definitely a powerful feature that was recently added to MSSQL server. Unfortunately, the current version of the BDE (5) does not support this functionality. The only way to get this out of your SQL Server is to bypass the BDE entirely with, for example, an ADO connection. In that situation, the lock is acquired by this simple SQL statement:


tablename is the name of your table and condition is a conditional statement that should force only one record to be returned. The WITH clause will cause all rows returned to be locked with a row level lock, but if you need multiple rows locked you might want to look at another type of lock. This statement must be run in the context of a transaction, and this lock will persist until that transaction is committed or rolled back.

If you then run the MSSQL stored procedure sp_lock() during the timeframe of the transaction, you will see that your table has a lock of type RID, which denotes a row level lock. If you were to fire this exact SQL statement in a BDE application, sp_lock() would show a lock of either type TAB (table level) or PAG (page level).

Generated 8:01:27 on Aug 25, 2019