我有两张桌子,COURSE
和OFFERING
。他们的专栏是:
COURSE (
courseId,
title,
cost,
duration
)
和
OFFERING (
offeringID,
instructor,
startDate,
endDate,
courseId,
locationId
).
我想配置一个触发器,确保COURSE
不能在 12 月提供持续时间为 5 天的课程(来自表格的持续时间列)(来自表格的startDate
列OFFERING
)。我想出了以下 SQL 查询:
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;
触发器已创建,但出现错误。