create or replace
trigger audit_att_eval
AFTER INSERT OR UPDATE OF evaluation ON attendance
FOR EACH ROW
DECLARE
fname VARCHAR2(22);
sname VARCHAR2(22);
ctitle VARCHAR(30);
ostartdate DATE;
oinstructor VARCHAR2(12);
BEGIN
SELECT student.first_name, student.surname, course.title, offering.start_date, offering.instructor
INTO fname, sname, ctitle, ostartdate, oinstructor
FROM student, course, offering, attendance
WHERE student.student_id = attendance.student_id
AND attendance.offering_id = offering.offering_id
AND offering.course_id = course.course_id;
IF (:NEW.evaluation = 0)
THEN
INSERT INTO eval_audit
VALUES (fname, sname, ctitle, ostartdate, oinstructor, :NEW.evaluation);
END IF;
END;
这可以编译,但是当我通过尝试更新现有的出勤率来测试它时。评估我收到以下错误:
Error report:
SQL Error: ORA-04091: table.ATTENDANCE is mutating, trigger/function may not see it
ORA-04088: error during execution of trigger 'OPS$1022005.AUDIT_ATT_EVAL'
04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
*Cause: A trigger (or a user defined plsql function that is referenced in
this statement) attempted to look at (or modify) a table that was
in the middle of being modified by the statement which fired it.
*Action: Rewrite the trigger (or function) so it does not read that table.
一如既往,我将不胜感激任何帮助引导我走向正确的方向。