sql - Mutating table exception when selecting max(date column of TABLE_X) in an after update trigger for TABLE_X -
i have trigger (sorry can't display actual sql because of company rules , different machine):
create or replace trigger tr_table_x_au after update on table_x each row declare cursor cursor_select_fk select fk_for_another_table table_y y, table_z z :new.joining_col = y.joining_col , y.joining_col = z.joining_col , :new.filter_condition_1 = y.filter_condition_1 , :new.filter_condition_2 = y.filter_condition_2 , :new.some_date_col = (select max(some_date_col) table_x filter_condition_1 = :new.filter_condition_1 , filter_condition_2 = :new.filter_condition_2) begin rec in cursor_select_fk loop pck_some_package.some_proc(rec.fk_for_another_table); end loop; end tr_table_x_au;
we resulted triggers since enhancement. nested query selecting max date seems cause of problem. changing sysdate results no exceptions. idea on how can max date during execution of trigger table_x? thanks!
edit: also, seems similar functions such count,sum,etc... produces same error. knows workaround this?
a mutating table table being modified update, delete, or insert statement, or table might updated effects of delete cascade constraint.
the session issued triggering statement cannot query or modify mutating table. restriction prevents trigger seeing inconsistent set of data.
trigger restrictions on mutating tables
which means, cannot issue max(some_date_col)
on table_x
in row-level trigger.
compound trigger possible workaround.
Comments
Post a Comment