Subject | Re: [firebird-support] Re: Inserting only one row for each distinct id (ignoring duplicates) |
---|---|
Author | Kjell Rilbe |
Post date | 2008-11-24T09:34:23Z |
dinol.softedge wrote:
I don't think FB checks the entire set of pk:s before trying to insert
them. I'd rather expect that it inserts one by one, and if one already
exists, FB throws that exception at that piont. But upon exception, the
entire operation is rolled back, so nothing gets inserted.
What Helen told you is that the subquery will be reevaluated after each
single insert, and on that new evaluation it will see the records
already inserted. That's why her suggestion should insert only one of
each PK.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
> Thank you to everyone. One problem that each answer has though isThis shouldn't happen with my suggestion. Are you sure you got it right?
> that Firebird seems to check the records first before actually
> inserting the data and therefore still brings up the Violation of
> PRIMARY or UNIQUE KEY constraint "INTEG_36" on table "TBL_INVENTORY"
> error. Any other ideas?
I don't think FB checks the entire set of pk:s before trying to insert
them. I'd rather expect that it inserts one by one, and if one already
exists, FB throws that exception at that piont. But upon exception, the
entire operation is rolled back, so nothing gets inserted.
What Helen told you is that the subquery will be reevaluated after each
single insert, and on that new evaluation it will see the records
already inserted. That's why her suggestion should insert only one of
each PK.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64