Check Constraint question
727255Oct 10 2009 — edited Jan 7 2012Hi,
I have a question regarding creating a constraint against two tables. I have an FK in table_A that should check the constraint against two related tables. Table_A is the table that holds the FK and tables B and C hold the PK back to table A. The problem is with my constraint FK I receive the message ORA-02251: subquery not allowed here. I need to ensure that the AFK contains the FK value that is in either TABLE_B or TABLE_C .
In my create statement I have
CREATE TABLE TABLE_A
(_PK INTEGER NOT NULL ENABLE,
_FK INTEGER NOT NULL ENABLE,
CONSTRAINT A__PK PRIMARY KEY (_PK) ENABLE,
CONSTRAINT A__FK CHECK (_FK IN (SELECT FK FROM TABLEB UNION SELECT FK FROM TABLEC)) ENABLE
);
Thanks