table 突变发生在哪里(Oracle)?

Where does the table mutation take place here (Oracle)?

我现在正在处理 oracle SQL,并尝试创建触发器。出于某种原因,它向我显示了突变的 table 错误,但是,我根本看不到它在哪里发生突变(它只是一个 select,甚至没有计数,但是,它有连接)。我至少应该从哪里开始为解决方案编写复合触发器?似乎只有几个例子,它们离我太远,无法理解在这种特定情况下它应该如何工作。

  CREATE OR REPLACE TRIGGER "EVGENIJ_BOBROVICH"."FIX_UPD_LIMITS" 
BEFORE UPDATE OR DELETE ON "EVGENIJ_BOBROVICH"."MAP_CALCULATION_SHOP_LIMITS"
FOR EACH ROW
DECLARE
is_deleted_dependant VARCHAR2(1 BYTE);
is_editable_dependant VARCHAR2(1 BYTE);
BEGIN
SELECT IS_DELETE, IS_EDITABLE INTO is_deleted_dependant, is_editable_dependant
FROM MAP_CALCULATION MC INNER JOIN map_calculation_group MG
ON MC.ID_CALC = MG.ID_CALC INNER JOIN map_calculation_shop_limits MS ON MG.ID_GROUP = ms.id_group
WHERE :OLD.ID_GROUP = MG.ID_GROUP AND MG.ID_CALC = MC.ID_CALC;
IF UPDATING AND (is_editable_dependant = 'F' OR is_deleted_dependant = 'T') THEN
RAISE_APPLICATION_ERROR( -20004, '....Error......' );   
ELSIF DELETING AND (is_editable_dependant = 'F' OR is_deleted_dependant = 'T') THEN
RAISE_APPLICATION_ERROR( -20005, '...AnotherError...' );   
END IF;
END;
/

select 本身没有触发器(当然也没有 into 和 old,我使用绑定变量而不是 old)工作正常...

它发生在这里:

INNER JOIN map_calculation_shop_limits

您不能 select 来自您正在更新的同一个 table ...好吧,变异

为了更新目的,您

 FROM map_calculation mc
      INNER JOIN map_calculation_group mg ON mc.id_calc = mg.id_calc
      -- INNER JOIN map_calculation_shop_limits MS ON MG.ID_GROUP = ms.id_group       --> this
WHERE     :old.id_group = mg.id_group
      AND mg.id_calc = mc.id_calc
      AND mg.id_group = :new.id_group;          --> and this

对于删除,您将使用 :old.id_group,这意味着您需要将使用的代码重写为两部分:一个处理更新,另一个处理删除。