警告:使用编译错误创建触发器。 (ORACLE

时间:2016-04-10 14:39:54

标签: sql oracle plsql

我尝试创建一个触发器,检查教师是否已在此课程中教授此课程:

CREATE OR REPLACE TRIGGER C3
BEFORE INSERT ON classGroup
FOR EACH ROW
DECLARE teach NUMBER(10);
BEGIN
    SELECT count(*) INTO teach;
    from classGroup
    WHERE classId = :new.classId
    AND teacherId = :new.teacherId,
    AND sessionId = :new.sessionId;
        RAISE_APPLICATION_ERROR(-20002,'you cant teach 2 time the same class');

exception
    when no_data_found then
        -- do insert
END;
/

但我总是收到这条消息:

Warning: Trigger created with compilation errors.

表Classgroup包含:classId,groupId,sessionId,teacherId,desc

1 个答案:

答案 0 :(得分:1)

这是一个基本的语法错误。

有一个;教后和后,:new.teacherId

SELECT count(*) INTO teach
    from classGroup
    WHERE classId = :new.classId
    AND teacherId = :new.teacherId
    AND sessionId = :new.sessionId;