Re: SQL*Plus Constraints

From: Greg Hayes <Greg_at_hayford.demon.co.uk>
Date: Tue, 5 Jul 1994 11:16:56 +0000
Message-ID: <773407016snz_at_hayford.demon.co.uk>


In article <BGraham.7.2E15EB0A_at_GANDALF.OTAGO.AC.NZ>

           BGraham_at_GANDALF.OTAGO.AC.NZ "Bryce Graham" writes:

> Newsgroups: comp.databases.oracle
> Path: hayford.demon.co.uk!demon!pipex!sunic!EU.net!uunet!comp.vuw.ac.nz!
> canterbury.ac.nz!otago.ac.nz!n089012.otago.ac.nz!BGraham
> From: BGraham_at_GANDALF.OTAGO.AC.NZ (Bryce Graham)
> Subject: SQL*Plus Constraints
> Message-ID: <BGraham.7.2E15EB0A_at_GANDALF.OTAGO.AC.NZ>
> Lines: 18
> Sender: usenet_at_news.otago.ac.nz (News stuff)
> Nntp-Posting-Host: n089012.otago.ac.nz
> Organization: University of Otago
> Date: Sat, 2 Jul 1994 22:32:42 GMT
>
> Hi,
>
> I'm building a set of tables at the moment and I want to be able to check
> whether the age of an employee is > 16 and < 99. The employee's date of
> birth is entered into the table and I want a column constraint to
> automatically check that the age is between these two ages.
>
> I've tried using MONTHS_BETWEEN but it won't allow me to use the SYSDATE
> variable as the first date.
>
> Any ideas on how to get around this would be greatly appreciated.
>
> Post any request either to this newsgroup or I can be E-Mailed at
> IS40511_at_Otago.ac.nz.
>
> Thanks in Advance
>
> Bryce Graham
>

If disk space is not a problem then add a Date field to the table definition, with a DEFAULT value of sysdate. Then refer to this column in your CHECK constraint instead of referring to sysdate which is not permitted in a check constraint.

-- 
Alan Muster
Received on Tue Jul 05 1994 - 13:16:56 CEST

Original text of this message