Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> refer to SYSDATE function in a CHECK constraint--doable?
Greetings all,
I've got a table with a date field on a 8.1.6.0 db. I'd like to constrain the values entered into this field to be less than or equal to the date on which the record was entered. I figured a table-level check constraint would serve & so I ran:
ALTER TABLE TLB_COPIES
ADD (CONSTRAINT TLBCPY_DATE_LAST_LABEL_CK CHECK (DATE_LAST_LABEL <=
SYSDATE)
EXCEPTIONS INTO COMN_EXCEPTIONS)
And Oracle complained thus:
ADD (CONSTRAINT TLBCPY_DATE_LAST_LABEL_CK CHECK (DATE_LAST_LABEL <= SYSDATE)
*ERROR at line 2:
I've also tried using TO_DATE(SYSDATE) after running accross that expression in some code examples in the docs (does SYSDATE not return a date type?), but get the same error.
I've searched through metalink for this error, but everything I've found deals with how you've got to to_date() a date literal (e.g., no implicit conversions) and be sure to use a full four-digit year (as of 8.x I think). But I'm not seeing anything that refers to the sysdate function--is it just not allowed? I'm pretty sure you can use it as a DEFAULT...
Thanks!
-Roy
Roy Pardee
Programmer/Analyst
SWFPAC Lockheed Martin IT
Extension 8487
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Pardee, Roy E
INET: roy.e.pardee_at_lmco.com
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Liststo: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Mar 21 2002 - 14:48:24 CST
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message