Subject | Re: INSERT or Update and conflict |
---|---|
Author | svanderclock |
Post date | 2009-01-21T06:39:51Z |
yes, i was thinking to do like you say, handle the error in the
client interface... but is not a problem for firebird to receive too
lot of error like this (duplicate reccord or lock conflict?)
in case of error, is it better for the stability of firebird to
commit the transaction or rollback it (nothing was inserted or
updated cause of the error)
thanks by advance
stephane
--- In firebird-support@yahoogroups.com, Milan Babuskov <milanb@...>
wrote:
client interface... but is not a problem for firebird to receive too
lot of error like this (duplicate reccord or lock conflict?)
in case of error, is it better for the stability of firebird to
commit the transaction or rollback it (nothing was inserted or
updated cause of the error)
thanks by advance
stephane
--- In firebird-support@yahoogroups.com, Milan Babuskov <milanb@...>
wrote:
>the
> svanderclock wrote:
> > 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
> > same insert and unfortunatly one of them go in the violation ofprimary
> > key.... I just want to know the best way to handle suchsituation ?
>you
> It depends on what it means from business logic point of view. If
> really want to disallow two records with that value, then justignore
> the second insert that failed (maybe write to some log somewhere).Just
> check the SQL error code to make sure it failed because ofduplicate
> primary key.you
>
> If you want both to succeed and have two records, than obviously
> need to set some other field to be the primary key.conflict on
>
> > now in the same kind, sometime i get 'Update Error - lock
> > no wait transaction'. it's when 2 clients try to update the samerow at
> > the same time. here also how to handle such situation ? is itpossible
> > to force the update of the row by the second request instead ofraising
> > a lock conflict?Once
>
> Yes. Catch the lock conflict and retry from your application code.
> again, checking that it failed because of such error and notsomething
> else is desirable.
>
>
> --
> Milan Babuskov
> http://www.flamerobin.org
> http://www.guacosoft.com
>