Subject | Re: Best way to prevent simultaneous editing? |
---|---|
Author | Adam |
Post date | 2006-06-25T23:20:39Z |
> If a person is editing a particular invoice, I don't wantHi Sudheer,
> anybody else to edit or view that particular invoice (thru
> my application).
>
> Which way is the best to prevent this? Can I use a flag in
> the invoice master table and handle the situation or do a
> dummy update to invoice master and lock it?
Do you really want to prevent someone viewing the invoice? A good
thing about Firebird is that it will still display the old details of
the invoice until the transaction editing the invoice commits.
You are going to want to set a flag on the master table, keeping in
mind that other transactions cannot see this flag until you commit.
You will need make sure your application only allows a detail record
of an invoice to be edited if you have set the flag. If you do take
this approach, you need a plan to deal with the fact that someone may
just pull the power plug from the workstation and your record will be
left in a locked state.
You could do a dummy update (or better still select with lock as that
does not fire triggers) BUT this transaction will need to be active
for as long as it takes the user to type in the adjustments. User
actions are by definition slow. They do annoying things like going
home leaving the screen open which can make a real mess of garbage
collection. If you do decide to take this approach, you absolutely
must have some sort of timeout.
The first approach though is my preferred.
Adam