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

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

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; -- dont forget it!!!
END;

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).

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

Leave a Reply

Your email address will not be published.