Subject Re: Deadlock question
Author Adam
--- In firebird-support@yahoogroups.com, Robert martin <rob@...>
wrote:
>
> Hi
>
> If I run the following SQL from two applications / threads
> simultaneously should I get a deadlock (Where aPK is the same
record)?
>
> UPDATE aTable SET Qty = Qty + :Qty WHERE aPK = :aPK;

The behaviour depends on the isolation mode, but Yes you will get a
lock conflict.

If you are using a NOWAIT transaction, you will receive an exception
immediately. If you are using a WAIT transaction, the second
transaction will 'freeze' to see what the first does. If the first
commits then the second receives an exception. If the first rolls
back, then the second will succeed in its update.

If you are maintaining a single counter for qty of an item, then you
effectively serialise it. There are better methods to maintain a
count which do not serialise.

Adam