I have two tables, COURSE and OFFERING . Their columns are:
COURSE ( courseId, title, cost, duration )
and
OFFERING ( offeringID, instructor, startDate, endDate, courseId, locationId ).
I want to set up a trigger that ensures that courses lasting 5 days (from the COURSE table duration column) cannot be offered in December (from the startDate column of the startDate table). I came up with the following SQL query:
CREATE OR REPLACE TRIGGER checkDuration BEFORE INSERT OR UPDATE ON (course c JOIN offering o ON c.courseId = o.courseId) FOR EACH ROW BEGIN IF ((to_char(:new.startDate, 'fmMONTH') = 'DECEMBER') AND duration = 5) THEN raise_application_error(-20001, 'Courses of five days duration cannot be run in December'); END IF; END;
A trigger was created, but with errors.
source share