Subject Re: [firebird-support] compound FK fails
Author Helen Borrie
At 12:45 AM 4/03/2008, you wrote:
>I can't see why this is failing, I know it's not great structure but I
>didn't design it.
>
>CREATE TABLE TBLCUSTOMASSETEDIT (
> GROUPID BIGINT NOT NULL,
> ASSETID Integer NOT NULL,
> CONSTRAINT PK_TBLCUSTOMASSETEDIT PRIMARY KEY (GROUPID,ASSETID)
>);
>
>CREATE TABLE TBLCGCHECKGRID (
> GROUPID BIGINT NOT NULL,
> ASSETID Integer NOT NULL,
> CONSTRAINT PK_TBLCGCHECKGRID PRIMARY KEY (GROUPID,ASSETID)
>);
>
>ALTER TABLE TBLCGCHECKGRID ADD CONSTRAINT FK_TBLCGCHECKGRID_1 FOREIGN
>KEY (GROUPID,ASSETID) REFERENCES TBLCUSTOMASSETEDIT(GROUPID,ASSETID)
>ON DELETE CASCADE;
>
>violation of FOREIGN KEY constraint '""'. violation of FOREIGN KEY
>constraint "PK_TBLCUSTOMASSETEDIT" on table "TBLCUSTOMASSETEDIT".
>Foreign key reference target does not exist.

You'll have to commit the other stuff before attempting the create the FK.

./heLen