Subject Re: Problem creating foreign key
Author Graham Reeves
Hello all

I have two tables that have a one-to-many relationship. in the child table I am trying to create a foreign key referencing the parent. When I execute the DDL the it gives me the following error...

"This operation is not defined for system tables.
unsuccessful metadata update.
STORE RDB$REF_CONSTRAINTS failed.
action cancelled by trigger (1) to preserve data integrity.
Name of Referential Constraint not defined in constraints table."

Obviously there is something that wrong, but I'm not exactly sure :-(

Below are the table definitions...

CREATE TABLE SKYSTATUS
(
STATUSCODE VARCHAR(5) NOT NULL,
DESCRIPTION VARCHAR(100) NOT NULL,

PRIMARY KEY (STATUSCODE)
);

Create Unique Index xSkyStatusDescription on SkyStatus(Description)

CREATE TABLE SKYCLIENTDIARY
(
ACCNO VARCHAR(20) NOT NULL,
DATEOFENTRY TIMESTAMP NOT NULL,
TIMEOFENTRY VARCHAR(20) NOT NULL,
CUSER VARCHAR(30),
CDATE TIMESTAMP,
CTIME VARCHAR(20),
ENTRYTYPE VARCHAR(100) NOT NULL,

PRIMARY KEY (ACCNO, DATEOFENTRY, TIMEOFENTRY),
FOREIGN KEY (EntryType) REFERENCES SkyStatus (Description)
ON UPDATE CASCADE
ON DELETE CASCADE
);

If anyone has any ideas I would appreciate it.

TIA
GRAHAM




[Non-text portions of this message have been removed]