If you have a record version number field in the table then you can read it 
for the record of interest. When you go to update the record you specify the 
expected version number in the update equivalent to the SQL WHERE along with 
the field id so if the version number has been incremented by another user 
update, your update will fail because the WHERE version=x part of the update 
will not match.

I think this depends on the database you use as well. I thought most modern 
databases apply a read lock while you are looking at a record and if you try 
to update the lock is upgraded to a write lock and if someone else beat you 
to the update an error is thrown. You would need to check your database 
documentation looks for pessimistic vs optimistic locking or just locking.

Reply via email to