anonymous
2011-11-23 12:15:50 UTC
Basically im trying to have a constraint on field on one table based on another table.
So in my datbase i have a police table and appointment table.
In my police table there are many tuples with different ranks.
In the appointmnet table there is a police_id as a foreign key. However i need to make it so that only sergeants can make appointmnets (rank_id = 2)
when i put a constraint as
CHECK( POLICE_ID IN ( SELECT police_id from police where rank_id = 2))
But oracle doesnt allow constraints with subqueries.
can anyone help me get around this?
Cheers,
Ben