Subject Re: [firebird-support] Unable to re-create foreign key
Author Helen Borrie
At 09:24 AM 15/11/2006, you wrote:
>I've had a database that has shown problems (see
>http://tech.groups.yahoo.com/group/firebird-support/message/78918).
>
>I've dropped the foreign keys and primary index that was causing the
>problem and re-created the primary index. All is okay--until I try to
>re-create a foreign key with:
>
>alter table ACTIONLOG
>add constraint FK1_ACTIONLOG
>foreign key (CLIENT_ID)
>references CLIENTINFO(CLIENT_ID)
>
>I get the following exception:
>
>Cannot commit transaction:
>violation of FOREIGN KEY constraint "".
>violation of FOREIGN KEY constraint "PK_CLIENTINFO" on table "CLIENTINFO".
>
>I've checked
>
>1) all client_id values in ActionLog are in ClientInfo:
>
> select client_id from ClientLog where not client_id in
> (select Client_Id from ClientInfo)
>
>(which returns empty).
>
>2) There are no null client_id values in ActionLog (or ClientInfo).
>
>There is another tables where table.client_id has a fk on ClientInfo
>and that one restored the fk just fine.
>
>What might I look at?

It looks as though you might have been trying to create the foreign
key whilst the parent constraint was uncommitted.

./heLen