Oracle Database Enforce CHECK on multiple tables

Posted by GigaPr on Stack Overflow See other posts from Stack Overflow or by GigaPr
Published on 2010-04-11T13:53:56Z Indexed on 2010/04/11 14:53 UTC
Read the original article Hit count: 308

Filed under:
|
|

I am trying to enforce a CHECK Constraint in a ORACLE Database on multiple tables

CREATE TABLE RollingStocks ( 
  Id NUMBER,
  Name Varchar2(80) NOT NULL,           
  RollingStockCategoryId NUMBER NOT NULL,            
  CONSTRAINT Pk_RollingStocks Primary Key (Id),
  CONSTRAINT Check_RollingStocks_CategoryId  
  CHECK ((RollingStockCategoryId  IN (SELECT Id FROM FreightWagonTypes)) 
        OR 
        (RollingStockCategoryId  IN (SELECT Id FROM LocomotiveClasses)))       
);

...but i get the following error:

*Cause: Subquery is not allowed here in the statement. *Action: Remove the subquery from the statement.

Can you help me understanding what is the problem or how to achieve the same result?

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle