We seem to have a misunderstanding over the definition of "optomistic 
locking".

To me, "optimistic" locking means the application doesn't do any locking 
when a record is read. All it does it to retain the timestamp of the record 
when it was read.

When the application wants to write edited records back to the database, it 
does something like...

BEGIN TRANSACTION
 re-read the record(s) to be written
 compare the timestamp with the timestamp when the record was read
 if they are different, abort the transaction, saying to the user something 
  like "Can't update the database, someone else has changed it".
 write the edited record(s), updating the timestamp
END TRANSACTION

What you do when another user has changed a record is the tricky bit - you 
can throw away the user's edits, and start again, you can offer to 
overwrite the other user's updates (but be careful if there are related 
records), or you can be really clever and try to merge the two sets of 
changes.

-- 
Nikki Locke, Trumphurst Ltd.      PC & Unix consultancy & programming
http://www.trumphurst.com/


Reply via email to