Efficient way to get updated column names on an after update trigger

Viewed 3134

I've come up with the following trigger to extract all the column names which are updated when a table row update statement is executed...

but the problem is if there are more columns(atleast 100 cols), the performance/efficiency comes into concern

sample trigger code:

set define off;
create or replace TRIGGER TEST_TRIGG
AFTER UPDATE ON A_AAA
FOR EACH ROW
DECLARE
    mytable varchar2(32) := 'A_AAA';
    mycolumn varchar2(32);
    updatedcols varchar2(3000);

    cursor s1 (mytable varchar2) is 
        select column_name from user_tab_columns where table_name = mytable;
begin

        open s1 (mytable);

        loop
            fetch s1 into mycolumn;
            exit when s1%NOTFOUND;

            IF UPDATING( mycolumn ) THEN
                updatedcols := updatedcols || ',' || mycolumn;
            END IF;

        end loop;
        close s1;
        --do a few things with the list of updated columns
    dbms_output.put_line('updated cols ' || updatedcols);
end;
/

Is there any alternative way to get the list?

Maybe with v$ tables (v$transaction or anything similar)?

2 Answers
Related