Subject Re: [firebird-support] A question about "with lock"
Author Helen Borrie
At 10:30 AM 2/03/2005 +0200, ibrahim Bulut wrote:


>Hi all,
>i have a question about with lock clause and triggers
>
>if i read records with "with lock" clause, if there are before/update
>triggers for table, are they fire

Yes. This form of pessimistic locking does not affect your triggers.


>i read the record like this
>
>select * from table
>where id = 5 with lock
>
>and there is an before update trigger of this table
>and there is an after update trigger of this table
>
>are theese triggers is fire with lock clause

Yes.


>how firebird server lock this records

Well, I strongly advise you to understand how WITH LOCK works -- study the
release notes carefully. You will get strange lock conflicts AND locked
records that really are not locked when you suppose they are, unless you
take extreme care to operate on the lowest possible number of records in
your SELECT - ideally, not more than one record - and to understand clearly
the different effects with different transaction configurations.

WITH LOCK is *not* part of what you do in the normal operation of a
Firebird system. Firebird is extremely good at taking care of multi-user
conditions and it was *not* designed for pessimistic locking. The very
worst thing you could do is to use WITH LOCK as a substitute for proper
understanding and management of transactions.

./helen