Subject Re: [firebird-support] Locking mechanisms
Author Joseph Osende
Hi, Sandy,

> 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?
>

I think that you may wish to consider to kind of solutions :

transaction isolation
events

May be it could be possible for you to :

to generate an event related to your "invoice run"
your application could "catch" this event "asynchronously" and react
accordingly
(i.e. in case it's modyfying an invoice, then it could :
start a transaction
check whether this invoice was changed by "invoice run" and so
forth
)

Please, notice that I've never used event related stuff myself !

Cheers,

Joseph.