Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: New Check Constraint Condition Question...

Re: New Check Constraint Condition Question...

From: <owais_anjum_at_my-deja.com>
Date: Sun, 12 Sep 1999 07:45:34 GMT
Message-ID: <7rflmr$fqv$1@nnrp1.deja.com>


In article <37DA9467.194226C6_at_baynet.net>,   Stephen Hurrell <hurrells_at_baynet.net> wrote:
>
> --------------34A5B448F364EF595BC6645E
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> >
>
> Hello
>
> First off I'd like to thanks everyone who respond to my first
constraint
> question.
> The solution that I chose was;
>
> event_year = to_char(event_date,'YYYY')
>
> However the trigger approach may become applicable.
>
> Anyways I now what to know if you can use sysdate in a calculation.
>
> I have two fields "age" and "birth_date" that are related as;
>
> age = yearof(sysdate)-yearof(birth_date)
>
> QUestions;
>
> 1. Can I use sysdate here or like this?
> 2. There are Y2K issues with the above
>
> Any ideas?
> STeve
> ----EOT
Hello
You can not use SysDate in a check constraint. I am pasting here all the limitations associated with the check constraint. (This is from Oracle 8 manual)

  1. The condition of a CHECK constraint can refer to any column in the table, but it cannot refer to columns of other tables.
  2. can't have queries to refer to values in other rows
  3. can't have calls to the functions SYSDATE, UID, USER, or USERENV
  4. can't use the pseudocolumns CURRVAL, NEXTVAL, LEVEL, or ROWNUM
  5. can't use date constants that are not fully specified

Cheers
Owais

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Sun Sep 12 1999 - 02:45:34 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US