Reputation: 59
So I am making an oracle database for a university coursework. My coursework is to make a database for an airlines.
The problem I am having is that I have to make sure that the passport expiry date on a new passenger record is not less than the current date (that is, make sure that the person's passport is still valid).
could someone please help me out with creating a trigger to do this? I have the entity PASSPORT_EXPIRY in table PASSPORT set to the datatype DATE.
cheers
Upvotes: 0
Views: 1549
Reputation: 16673
i am assuming you can create the trigger..(?)
you will be comparing to SYSDATE
- the built in holder for today (right now).
inside a trigger - you are allowed to write PL SQL. so you can have IF checks.
your check will be something like
IF SYSDATE > PASSPORT_EXPIRY THEN
or you can probably write this into a select statement where you query maybe the days between now and expiry..
SELECT SYSDATE - PASSPORT_EXPIRY INTO diff
from PASSPORT WHERE ...
then check if diff < 0.. etc.
Upvotes: 1