使用:new的PL / SQL触发错误错误变量

时间:2018-12-03 11:40:07

标签: oracle plsql

我有两个主要的表Student and Classs,它们之间有许多关系,所以我创建了一个中间表。每当我在Student上插入数据时,它就会填充在这两个触发器上生成的数字:insert_Students_trigger和insert_Classes_trigger。只有最后一个触发器给我错误的错误的绑定变量new.Id_Class

任何想法为何?

CREATE SEQUENCE id_Students_inc start with 1
increment by 1;

CREATE SEQUENCE id_Classes_inc start with 1
increment by 1;

CREATE OR REPLACE TRIGGER insert_Students_trigger BEFORE INSERT on Students
FOR EACH ROW
  BEGIN

    :new.ID_Student := id_Student_inc.nextval;

  END;

CREATE OR REPLACE TRIGGER insert_Classes_trigger BEFORE INSERT on Classes 
FOR EACH ROW
  BEGIN

    :new.ID_Classe := id_Class_inc.nextval;

  END;



CREATE OR REPLACE TRIGGER Students_Classes_trig AFTER INSERT ON Students
FOR EACH ROW
  BEGIN

    INSERT  INTO StudentsClasses (ID_Student, ID_Class)
    VALUES (:new.ID_Student,:new.ID_Class);
  end;

0 个答案:

没有答案