Subject Re: [firebird-support] INSERT or Update and conflict
Author Anderson Farias
Hi,

>so some time i get some violation of PRIMARY or UNIQUE KEY when 2
>client do an INSERT because at the same time these 2 clients do the
>same insert and unfortunatly one of them go in the violation of primary
>key.... I just want to know the best way to handle such situation ?

If you can, use GENERATORs


>now in the same kind, sometime i get 'Update Error - lock conflict on
>no wait transaction'. it's when 2 clients try to update the same row at
>the same time. here also how to handle such situation ?

Keep transactions as short as possible. This is not a real *error*, it's
just saying you can't update 'couse someone else is already updating. Handle
this and show a more friendly message to your user saying he need to try
again later (or something)


> is it possible to force the update of the row by the second request
> instead of raising a lock conflict?

YES. Setup your transactions as WAIT

This way, users don't get a messaging saying it can't update, instead, it
will wait until the transaction that updated the record is commited or
roledback. USE THIS WITH CAUTION.


Regards,
Anderson Farias