Subject | Re: [firebird-support] INSERT or Update and conflict |
---|---|
Author | Milan Babuskov |
Post date | 2009-01-20T20:23:51Z |
svanderclock wrote:
really want to disallow two records with that value, then just ignore
the second insert that failed (maybe write to some log somewhere). Just
check the SQL error code to make sure it failed because of duplicate
primary key.
If you want both to succeed and have two records, than obviously you
need to set some other field to be the primary key.
again, checking that it failed because of such error and not something
else is desirable.
--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com
> so some time i get some violation of PRIMARY or UNIQUE KEY when 2It depends on what it means from business logic point of view. If you
> 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 ?
really want to disallow two records with that value, then just ignore
the second insert that failed (maybe write to some log somewhere). Just
check the SQL error code to make sure it failed because of duplicate
primary key.
If you want both to succeed and have two records, than obviously you
need to set some other field to be the primary key.
> now in the same kind, sometime i get 'Update Error - lock conflict onYes. Catch the lock conflict and retry from your application code. Once
> 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 ? is it possible
> to force the update of the row by the second request instead of raising
> a lock conflict?
again, checking that it failed because of such error and not something
else is desirable.
--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com