Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Table Constraint to reject record on insert

sharpeApr 26 2013 — edited Apr 26 2013
Is it possible to create a table constraint that would reject records not meeting a specific constraint condition?

I need to reject records being inserted to my Induction_Info table where the bundle does not exist in my Bundle table, but on only when Induction_Info.Project_Code = 'TEST'. Is this possible?

I've attempted this:
ALTER TABLE EXFC.INDUCTION_INFO ADD 
CONSTRAINT chk_induction_info$bundle
 CHECK (bundle in(select bundle from bundle)) ENABLE
 VALIDATE
But when I attempt to compile I get the message:
ORA-02251: subquery not allowed here
I don't even know if what I'm attempting is possible. Can you help? I'd certainly appreciate any help. Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2013
Added on Apr 26 2013
11 comments
969 views