Subject Locking mechanisms
Author Sandy
Hello,

I have a classic distributed locking problem here, and am unsure about
solving it using the Firebird system.

The problem is this:

On one machine, someone starts to edit an invoice and keeps the invoice open
for a while. On another machine, while the invoice on the first machine is
still open, someone starts to do an "invoice run" (this processes all
outstanding invoices and groups them for printing). An outstanding invoice
is flagged by an invoice number of 0 (zero). The "invoice run" process
updates each outstanding invoice with a non-zero invoice number.

However, if the invoice open on the first machine had an invoice number of
zero, then when that invoice is saved, it can overwrite the new correct
invoice number which had been assigned by the "invoice run" process.

To put it another way, transaction A starts editing a record. While this is
going on, transaction B opens the same record and makes a change, and
commits. Later on, transaction A finally commits, overwriting the work of
transaction B.

I am accustomed to solving this sort of problems with locks, but from what
I've read, Firebird doesn't support much in the way of locking. Does anyone
know the solution to this of problem?

Many thanks,

Sandy