1

如果课程日期与会话所在的星期几不匹配,我编写了以下触发器以防止用户将课程分配给会话。

CREATE OR REPLACE TRIGGER trig_alternative_classDate
AFTER INSERT OR UPDATE ON ALTERNATIVE
FOR EACH ROW
DECLARE
    classdate CHAR;
    sessionday VARCHAR;
BEGIN
    SELECT to_char(to_date(class.class_date), 'Day') INTO classdate, sessions.day INTO sessionday
    FROM SESSIONS, CLASS, DUAL, LOCATION, ALTERNATIVE
    WHERE class.class_id = alternative.class_id
    AND alternative.location_id = location.location_id
    AND sessions.location_id = location.location_id;
    IF sessions.day != to_char(to_date(class.class_date), 'Day')
    THEN raise_application_error(-20999,'Invalid Class Date - Class Date does not match Session Day');
    END IF;
END;
/

但是,当我运行触发器时收到一条错误消息

Warning: Trigger created with compilation errors.

SQL> show error trigger trig_alternative_classDate
Errors for TRIGGER TRIG_ALTERNATIVE_CLASSDATE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
5/2  PL/SQL: SQL Statement ignored
5/80 PL/SQL: ORA-00923: FROM keyword not found where expected

有人可以帮忙吗?

4

1 回答 1

2

删除第二个 INTO - 只需要一个 INTO:

INTO classdate, sessions.day INTO sessionday
于 2013-02-26T15:37:00.673 回答