Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Date of Birth validation

user991291Feb 22 2009 — edited Feb 23 2009
hello,

I am new to Oracle and am trying to valid the DOB. I only want person to be over 16years old. I tried using sysdate in the contraint but realise after reading around that system variables cannot be used and i have to use a trigger. Below was the constraint that i was trying (just so that you understand what i'm trying to do):

bq. ALTER TABLE tableName \\ ADD CONSTRAINT DOB_ck CHECK (dateofbirth IN ( dateofbirth < SysDate - 16 ));
How can I use a trigger or something else to ensure the DOB entered meets this condition?

Another problem that i have is that i want to ensure that the exam date entered is less than or equal to the SYSDATE (examDate <= SYSTDATE). Below is the constraint:

bq. ALTER TABLE tableName \\ ADD CONSTRAINT ExamDate_ck CHECK (ExamDate IN ( SysDate >= ExamDate))
How can I ensure that the date entered is past or present NOT future?

Any help would be much appreciated.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2009
Added on Feb 22 2009
4 comments
1,430 views