Board index » delphi » Record lock

Record lock


2005-05-19 05:37:43 PM
delphi223
stored procedures / triggers IB 6.0.2
is there a way to lock a record for editing?
and / or
is there a way to find out if another user has modified a record after
it is selected (queried?) and before the changes are posted?
Thanks,
Michael Qua
 
 

Re:Record lock

InterBase uses optimistic locking. If you want to lock a record update
the record and set any field to its current value. The record will
remain locked for the life of the transactions.
The only way to find out of someone else has changed a record and
commited the change is to requery the record.
--
Bill Todd (TeamB)
 

Re:Record lock

Michael Qua writes:
Quote
stored procedures / triggers IB 6.0.2

is there a way to lock a record for editing?

and / or

is there a way to find out if another user has modified a record after
it is selected (queried?) and before the changes are posted?
There is no explicit record locking in InterBase. A record is automatically
locked only when you actually make an update to it (and for as long as that
transaction persists).
If you want to lock "for" editing, then you need to store a field yourself
that would be updated with a value, like user id, when a user wants to edit
it. When other users access this record, the app can check this field.
Once a user has finished editing a record (and committing the transaction)
then other users can freely post changes. The only way to know if another
user has changed anything at that point is to first query the record again
and compare fields. Rather than comparing all fields, an alterntaive is to
have a Version field in your tables that is updated (via trigger) every time
a record is updated. The you only need to check this one field.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"Democracy, without the guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman
 

Re:Record lock

Hello, Michael!
Michael Qua writes:
Quote
stored procedures / triggers IB 6.0.2

is there a way to lock a record for editing?

and / or

is there a way to find out if another user has modified a record after
it is selected (queried?) and before the changes are posted?
there is a great article at
www.interbase-world.com/en/articles/805.php
about record locking.
--
Dmitri Kouzmenko, www.ibanalyst.com
 

Re:Record lock

Please see
support.borland.com/entry!default.jspa?categoryID=157&externalID=1431&fromSearchPage=true
It's an article written long ago, but still true.
Michael Qua writes:
Quote
stored procedures / triggers IB 6.0.2

is there a way to lock a record for editing?

and / or

is there a way to find out if another user has modified a record after
it is selected (queried?) and before the changes are posted?

Thanks,

Michael Qua