I have a table like this:
StudentID Student Name Birthdate Student Birthplace Gender Height Weight
--------- --------------- --------- ------------------
You have a Date of Birth. So you need to determine that the DoB is at least sixteen years before today. There are various different ways of doing this; here's one using an interval literal.
create or replace trigger students_biur
before insert or update on students for each row
begin
if (:new.student_birthdate + INTERVAL '15' YEAR ) < sysdate
then
raise_application_error( -20000, 'This student is too young be registered.');
end if;
end;
This trigger also checks for updates, to prevent subsequent changes invalidating an student.
The trigger name students_biur
is just a convention I use: the table name with a suffix indicating *B*efore *I*nsert *U*pdate for each *R*ow.
RAISE_APPLICATION_ERROR is a standard procedure for throwing user-defined exceptions with a message. Find out more.
Oracle reserves the range -20999 to -20000 for user-defined errors; any other number may clash with a oracle-defined exception.