Subject Re: [firebird-support] Help with Alter table cascade delete
Author Bogusław Brandys
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:
>
> CREATE TABLE InflationDataSets (
> InflationDataSetID SMALLINT PRIMARY KEY,
> SetupID SMALLINT NOT NULL,
> InflationDataSetNam e VARCHAR(255) NOT NULL
> )
>
> CREATE TABLE InflationEntries (
> InflationDataSetID SMALLINT NOT NULL,
> YYear SMALLINT NOT NULL,
> AllGoodsIndex FLOAT NOT NULL,
> MedicalCostIndex FLOAT NOT NULL,
> WageIndex FLOAT NOT NULL
> )


COMMIT;


> ALTER TABLE InflationEntries
> ADD CONSTRAINT PK_InflationEntries
> PRIMARY KEY(InflationDatase tID, YYear);
>
> My Alter table statement is
>
> ALTER TABLE InflationEntries
> ADD CONSTRAINT FK_InflationEntries
> FOREIGN KEY (InflationDataSetID ) REFERENCES InflationDataSets
> (InflationDataSetID )
> ON DELETE CASCADE
>
> 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.
>
> Thanks in advance,
>
> Hardee Mahoney
> Washington, DC
>
> [Non-text portions of this message have been removed]
>
>