I am trying to add a constraint onto one of my tables to ensure that my workers maintain a station if and only if that station is in the state which the worker is currently employed. However, it seems that Oracle does not like subqueries inside constraints.
I remember from a class i took while back that sqlplus does not like checks across tables, when I do this:
ALTER TABLE STATION ADD CONSTRAINT Check_Worker CHECK (Maintainer IN (
SELECT *
FROM
STATION s,
FOREST f,
COVERAGE c,
STATE st,
WORKER w
WHERE
s.x BETWEEN f.MBR_XMin AND f.MBR_XMax AND
s.y BETWEEN f.MBR_YMin AND f.MBR_YMax AND
f.Forest_Id = c.Forest_Id AND
st.State = w.employing_state
)
);
it yells at me for:
'Question 3'
SELECT *
*
ERROR at line 2:
ORA-02251: subquery not allowed here.
So, do I have any options to easily get around this? Possibly multiple constraints?