更新触发器更新 table 中的所有行

Update trigger updating all rows in a table

我有一个触发器,我需要编写一个触发器来更新名为 StudentGrades 的 table 中的一行 'F'(其中包含 student_id、section_id 和成绩)当学生的状态在另一个名为 student 的 table 中更改为 'I' 时触发。我的问题是我认为它有效,但它会将所有值更新为 'F',无论状态更新到什么,它都会更新 [=25] 中所有 student_id 的成绩=].这是我的代码:

create or replace NONEDITIONABLE TRIGGER grades_trigger 

AFTER UPDATE ON STUDENT 

FOR EACH ROW 

 

BEGIN 

  UPDATE StudentGRADES 

  SET GRADE = 'F' 

  WHERE :NEW.STATUS= 'I'; 

END ;

如果需要,我可以 post 更多。

谢谢。

如果我没理解错的话,应该是

create or replace noneditionable trigger grades_trigger
  after update on student
  for each row
begin
  if :new.status= 'I' then                --> is student's status changed to I?
     update studentgrades set             --> yes, it is - so - update another table ...
       grade = 'F'
     where student_id = :new.student_id;  --> but not for ALL students - only for the one for which the trigger had fired
  end if;
end;