Subject Re: [firebird-support] Help with Add Constraint Foreign Key on cascade delete
Author Mark Rotteveel
Hardee Mahoney wrote:
> Hello,
>
> I am trying to set up an Foreign Key with a cascade delete but am getting an
> error message
>
> My tables are:

[....

>
> The error message (in FlameRobin) is
>
> SQL Message: -530
> violation of FOREIGN KEY constraint ""
> Engine Code: 335544466
> violation of FOREIGN KEY constraint "INTEG_2189" on table INFLATIONDATASETS
> Foreign key reference target does not exist
>
> The INTEG_2189 constraint is the primary key on InflationDatasets.
>
> I hope someone can indicate to me where I am going wrong. I have a lot of
> tables I would like to develope similar delete cascades for.

I can reproduce this in Firebird 2.1.2 and 2.5 beta 1 if there is a
record in INFLATIONENTRIES with an INFLATIONDATASETID that does not
exist in INFLATIONDATASETS.

In Firebird 2.1.2 the message is exactly like yours, in Firebird 2.5
beta 1 the message is (slightly) better:
SQL Message : -530
violation of FOREIGN KEY constraint ""

Engine Code : 335544466
Engine Message :
violation of FOREIGN KEY constraint "FK_INFLATIONENTRIES" on table
"INFLATIONENTRIES"
Foreign key reference target does not exist

So to fix this, you will need to add the missing INFLATIONDATASETID into
INFLATIONDATASETS.


--
Mark Rotteveel