Hi, I am working on my seminar thesis and I cannot get through with this problem: I have a table of students with a column birth_date and I only want to allow stdents UNDER 18 years old to be in my database. I want to use DateAdd function to do this or a trigger. Can you help me with how the CONSTRAINT should look like? I have come up with this but it doesn't seem to be working ("Missing expression" error returns).
CREATE TABLE student (
id_student INTEGER NOT NULL,
name VARCHAR2(50) NOT NULL,
birth_date DATE NOT NULL
);
ALTER TABLE student
ADD CONSTRAINT CheckAge CHECK (birth_date > DATEADD(date(), 'DD.MM.YYYY', 0, 0, -18)) ;
This should be added into the table:
INSERT INTO student (id_student, name, birth_date) VALUES ('1', 'John', '01.01.2012');
This should not be added into the table:
INSERT INTO student (id_student, name, birth_date) VALUES ('1', 'John', '01.01.2000');
Thanks a lot in advance for any help! (I am a beginner so although this may be trivial to you, it is not for me.)