Subject Referential constraints not defined
Author Tim Ledgerwood
Hi all,

I need to implement strict referential integrity for an accounts db. I keep
on getting the following error :

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
Statement: ALTER TABLE "ACCOUNTS" ADD CONSTRAINT "FK_ACCOUNT_ACCOUNT_TYPE"
FOREIGN KEY ("ACCOUNT_TYPE") REFERENCES ACCOUNTTYPETABLE ("RECORDNO")

Metadata for Sub accounts:

CREATE TABLE "SUB_ACCOUNTS"
(
"RECORDNO" "DOM_RECNUM",
"ACCOUNT_NUMBER" "DOM_CODE",
"SUB_ACCOUNT_NUMBER" "DOM_CODE",
"SUB_ACCOUNT_CODE" "DOM_CODESTRING",
"SUB_ACCOUNT_NAME" "DOM_DESCRIP",
"SUB_ACCOUNT_TYPE" "DOM_ACCTYPE",
"SUB_TAX_TYPE" "DOM_TAXRATING",
PRIMARY KEY ("RECORDNO"),
CONSTRAINT "UN_SUBACC_ACCOUNTCODE" UNIQUE ("SUB_ACCOUNT_CODE"),
CONSTRAINT "UN_SUBACC_ACCOUNTNUMBER" UNIQUE ("SUB_ACCOUNT_NUMBER")
);

Metadata for Account Type Table :

/* Table: ACCOUNTTYPETABLE, Owner: SYSDBA */

CREATE TABLE "ACCOUNTTYPETABLE"
(
"RECORDNO" "DOM_RECNUM",
"DESCRIPTION" "DOM_DESCRIP",
"ABBREVIATION" "DOM_ABBREV",
PRIMARY KEY ("RECORDNO"),
CONSTRAINT "UN_ACTYPE_ABBREV" UNIQUE ("ABBREVIATION")
);

Anyone know what I'm doing wrong?

Thanks

Tim


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