oracle - PL/SQL: What happens to collection contents inside a compound trigger in case of unhandled exception -
let's have following trigger:
create or replace trigger tr_test update or insert or delete on table_x compound trigger type array table of table_x%rowtype index binary_number; recs array; before each row number default rowids.count + 1; begin recs(i).a := nvl(:new.a, :old.a); recs(i).b := nvl(:new.b, :old.b); recs(i).c := nvl(:new.c, :old.c); recs(i).d := nvl(:new.d, :old.d); end before each row; after statement begin -- procedure here throw exception end after statement; end tr_test;
when after statement throws exception , unhandled, happen contents of array? automatically cleaned or remain in memory throughout session? if latter true, proper way handle prevent memory leaks? thanks!
pl/sql automatically takes care of variable scope you, don't have worry (in fact, there's nothing can explicitly anyway).
in case, array allocated when trigger starts (e.g. when first row inserted/updated/deleted), , remains until end of trigger (i.e. after after statement section finishes, or when exception raised , propogated caller).
when trigger goes out of scope, array no longer accessible, , oracle may deallocate memory used @ later point @ discretion.
Comments
Post a Comment