quote:
Two users could be setting the flag to locked at the same time, they would both read the flag as being zeroed, set it then try to update
You can update/attempt to update the row in a single statement, then check the result:
update bid_table
set lock_bit = 1,
lock_user = @Current_User,
lock_time = GETDATE()
where key_field = @Key_Value
and lock_bit = 0
IF @@ROWCOUNT = 1
--....Successful
ELSE
--....Unable to update row (either missing or locked)
-Dan
-Dan