help: Constaints Based on Data of Other Tables
Date: 28 Oct 1994 21:26:52 GMT
Message-ID: <38rqas$e11_at_martha.utk.edu>
Hi,
Do anybody know if I can use actual data of existing table for using
in constraint on a column in another table?
I have a table JOBS:
JCODE CHAR(2) NOT NULL
MIN_PAY NUMBER NOT NULL
MAX_PAY NUMBER NOT NULL
Unique(JCODE)
And I want to create a table ASSIGNMENT:
EID NUMBER NOT NULL
JCODE REFERENCES JOBS(JCODE)
SALARY ------!!------ - is is my question below
I am trying define column SALARY so that it could contain only values in the range set in the tabke JOBS for same JCODE and this is what I write:
SALARY NUMBER CHECK (
SALARY >= (select MIN_PAY from JOBS
where JOBS.JCODE = JCODE) AND SALARY <= (select MAX_PAY from JOBS
where JOBS.JCODE = JCODE))
Oracle complains on JOBS.JCODE: only simple column names allowed here
Is there another solution involving constraints?
Thank you very much.
-- David Zlotchenko Research Services The University of Tennessee Phone: (615) 974-2909 211 Hoskins Library Email: zlotchen_at_solar.rtd.utk.edu Knoxville, TN 37996 s_dzlotchenk_at_pstcc.cc.tn.usReceived on Fri Oct 28 1994 - 22:26:52 CET