由于某些触发器,我在将数据插入表时遇到问题。例如,以下触发器确保教授不是学生。
CREATE TRIGGER StudentOrProfessor2
AFTER INSERT ON Professor
FOR EACH ROW
BEGIN
DELETE FROM Professor
WHERE (:NEW.ID IN (SELECT Student.ID FROM Student));
END;
/
但是,当我在教授关系中插入一个元组时,出现以下错误。
SQL> INSERT INTO Professor VALUES('44415676', '246813579', 'Mathematics', '2', '000070000', '317', '3921234');
INSERT INTO Professor VALUES('44415676', '246813579', 'Mathematics', '2', '000070000', '317', '3921234')
*
ERROR at line 1:
ORA-04091: table S11022CZ.PROFESSOR is mutating, trigger/function may not see
it
ORA-06512: at "S11022CZ.STUDENTORPROFESSOR2", line 2
ORA-04088: error during execution of trigger 'S11022CZ.STUDENTORPROFESSOR2'
我不太确定该怎么做才能解决这个问题。