Re: subquery not allowed here

From: andrewst <member14183_at_dbforums.com>
Date: Sun, 20 Jul 2003 12:57:25 +0000
Message-ID: <3131240.1058705845_at_dbforums.com>


Originally posted by Allen
> Oracle 9.
> Trying to put a constraint. The date_time field in table Visit should
> be >= than date_admitted field in table Admission.
>
> CREATE TABLE Visit (
> adid INT REFERENCES myAdmission(adid),
> date_time DATE CONSTRAINT date_time_limits
> CHECK (date_time >= ALL
> (SELECT date_admitted
> FROM Admission, Visit
> WHERE Admission.adid = Visit.adid)),
> );
>
> I get subquery not allowed here. I don't have much experience, but as
> far as i can tell from my book this should work. But then again I just
> learned that oracle does not allow ASSERTION which is taught in this
> book; so is this the same problem? If yes could someone tell me how to
> get around this please.
Yes, Oracle check constraints are limited to expressions using column values from the single record being checked.

You would have to write a trigger to perform this check.

--
Posted via http://dbforums.com
Received on Sun Jul 20 2003 - 14:57:25 CEST

Original text of this message