Subject Re[2]: [ib-support] Foreign key violation
Author Gabriel Juncu
Hi Marcel,

Friday, January 17, 2003, 10:26:42 AM, Nicorici wrote:

> I think something missing in your letter.
> I just try it and everything is OK .(of course, I
> insert a record in table COUNTRY with ID=13)

> --- Gabriel Juncu <gjuncu@...> wrote:
>> [..stuff deleted..]
>>
>> Start Transaction 1 and execute:
>> UPDATE COUNTRY SET NAME = NAME where ID = 13;
>>
>> if I start Transaction 2 and execute:
>> INSERT INTO REGION (ID, NAME, COUNTRY_ID) VALUES (1,
>> 'SOME REGION NAME', 13)
>> before commiting Transaction 1, I get the error:
>>
>> Unsuccessful execution caused by system error that
>> does not preclude successful execution of subsequent
>> statements.
>> lock conflict on no wait transaction.
>> violation of FOREIGN KEY constraint
>> "FK_REGION_COUNTRY" on table "REGION".
>>
>> Both transactions are READ COMMITED, REC VERSION.

Of course you have to have a country with ID=13 :-)

I think that you have tried to do both in the same transaction. I have
encountered this error first in IB Objects when using pessimistic
locking on COUNTRY table (one user editing country name while other
user using that country in a Lookup Combo while inserting a new
region), and I can replicate the error in IB Expert, by opening two
SQL Editors, running the UPDATE in first editor and INSERT in the other.
DO NOT PRESS COMMIT TRANSACTION in first editor after Execute.

Regards,
Gabriel Juncu