Subject Re: [IBO] Opnions on this...
Author Lucas Franzen
> I can put everything inside a unique transaction, but it is not a good
> thing to have all the invoice lost if, at the commit time, IB reports a
> deadlock (maybe some other guy did another invoice using the same item and
> so updating the stock = conflict).
>
> There is much more complexity than I'm exposing here (actually some
> triggers also updates other tables that deal with quarrels, etc...)but at
> the moment I would like to hear your comments on how to make the above
> process in a way to minimize deadlocks.

If it's just that two or more users update the stock for the same item
you could use the WaitOnLock property of the transaction. If a deadlock
occurs the transaction will wait and then retry to post. If the deadlock
was just caused by this problem, the deadlocks will be avoided easily.

On the other hand you could store the stock information in a one-to-many
relationship to the items table, so you have no update on the items
table and a real nice overview when which amount of which item got out
and when it got in.
But in this case you have to sum the entries to get the current stock
AND it will be tough to prevent the stock being below zero....

Luc.