ORA-04091: table is mutating, trigger/function may not see it error during execution of oracle trigger

前端 未结 2 2061
名媛妹妹
名媛妹妹 2021-01-14 14:04

I have below trigger in which for FIELD_NAME field i want to insert value into FIELD_TRACKING table as \'Deactivation time of KPI in case of

相关标签:
2条回答
  • 2021-01-14 14:22

    Since you need informations from the table for which you created your trigger for(Select KPI_FREQ_TIME_UNIT FROM KPI_DEFINITION), you can get the KPI_FREQ_TIME_UNIT from the reference :NEW as it represents the new row (:NEW.KPI_FREQ_TIME_UNIT).

    0 讨论(0)
  • 2021-01-14 14:37

    Trigger cannot read the table (Select KPI_FREQ_TIME_UNIT FROM KPI_DEFINITION), that changes... you can access the value in this way: :new.KPI_FREQ_TIME_UNIT. More info: http://www.dba-oracle.com/t_avoiding_mutating_table_error.htm

    In other cases you can try to do it in autonomous transaction:

    create or replace TRIGGER RATOR_MONITORING_CONFIGURATION."TRG_TRK_KPI_DEFINITION" 
    AFTER UPDATE ON RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION FOR EACH ROW
    DECLARE
       PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
      -- ...
      COMMIT; -- don't forget it!!!
    END;
    
    0 讨论(0)
提交回复
热议问题