| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Concurrency Questions
Thank you very much! Lauri,
The solution you provided is so far the best one I think. The only problem with it is that the database (postgresql) will abort the transaction when trying to insert a record with duplicate key value.
I wonder how other people tackle this problem which I think it being inevitable.
Regards,
CN
> You could try to "shoot first and ask questions later" like this:
>
> BEGIN TRANSACTION;
> INSERT INTO inventory VALUES (NewItemId,NewItemQty);
> IF <duplicate error> THEN
> UPDATE inventory SET qty=NewItemQty WHERE ItemId=NewItemId;
> SELECT qty FROM inventory where ItemId=NewItemId;
> END TRANSACTION;
Received on Fri Jul 26 2002 - 00:22:02 CDT
![]() |
![]() |