Subject | Re: [firebird-support] Wrong foreign key error |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-09-24T08:51:24Z |
>I have a table called CUSTOMER, and another called HISTORY.Are you sure that the record in CUSTOMER is visible when you insert into HISTORY? If you in one transaction inserts a record in CUSTOMER and then try to insert through another transaction into HISTORY, then the record in CUSTOMER might not be visible. This is possible if the transaction that inserts into CUSTOMER is not committed before the other transaction starts (depending on the transaction isolation, it might not be enough that the CUSTOMER insertion is committed before you try to insert into HISTORY).
>HISTORY is linked to CUSTOMER by a foreign key, which
>means that you can only insert in HISTORY if there is a record in
>CUSTOMER in the foreign key fields, of course.
>
>Eventually my users get this error message when trying to insert a
>record in HISTORY table
>
>lock conflict on no wait transaction
>violation of FOREIGN KEY constraint "INTEG_33" on table "HISTORY"
>Foreign key reference target does not exist
>
>I don't understand why this error occurs, because i'm sure THERE
>IS a record in CUSTOMER with the foreign key record. This error
>would be correct if there was no record in CUSTOMER, but i'm
>sure there is.
>
>Any ideas will be very appreciated.
HTH,
Set