sql - Detect when a record is inserted or updated in oracle materialized view -
when updating existing record, deleted materialized view , re-inserted?
my problem update existing record , trigger being executed. want trigger fired new records.
i'm working oracle materialized view. have trigger like:
create or replace trigger my_view_trigger after insert on my_materialized_view each row begin --handle new record end;
i have tried changing "after insert" part "after insert or update" , had body in begins block like:
if inserting --handle new record elseif updating --handle modification of existing record end if;
but every update seen insert. there way detect updates in materialized view?
have considered materialized view logs? there seeded functionality around monitoring tables materialized view dependent on using materialized view log files (explicitly designed purpose).
for instance, have log file oracle apps table,inv.mtl_system_items_b.
next, if want monitor dml changes table, query log file:
select m_row$$ inv.mlog$_mtl_system_items_b dmltype$$ = 'i' , snaptime$$ >= trunc(sysdate));
the log file keeps track of dml type column, dmltypes$$ (i insert, u update, ...).
now suppose want know exact records being inserted today, might this:
select * inv.mtl_system_items_b rowid in (select m_row$$ inv.mlog$_mtl_system_items_b dmltype$$ = 'i' , snaptime$$ >= trunc(sysdate) )
one can modify triggers using variation of query monitoring these tables materialized view dependent on. there great value in leveraging seeded functionality (no need re-create wheel).
with respect triggers on materialized views, there issues:
-oracle advises against (see trigger documentation), except on updatable materialized views.
-an update of row in materialized view might done delete+insert
see tom kyte's writing on (https://asktom.oracle.com/pls/apex/f?p=100:11:0::::p11_question_id:672989600346945045).
generally, discouraged.
Comments
Post a Comment