Getting the triggering statement inside a trigger
Is there a way to get the SQL statement which fired the trigger, inside the trigger block ?
Say, I issue the following statement,
-----------------------------------------------
SQL> update scott.emp set sal = 0 ; -- Statement which fires trigger
SQL> commit;
Which fires the the following trigger,
----------------------------------------------
create or replace trigger scott.test_trigger
before update on scott.emp
begin
/*Code to store the SQL statement which fired the trigger */
insert into EMP_UPDATE_SQLS values ( **TRIGGERING_SQL_STMT** );
end;
Result expected:
---------------------
A row in EMP_UPDATE_SQLS , with the sql statement that fired the trigger, ( a row with the value 'update scott.emp set sal = 0' ).
Is it possible ???
Re: Getting the triggering statement inside a trigger
Quote:
Originally posted by ramesh_1600
Is there a way to get the SQL statement which fired the trigger, inside the trigger block ?
Say, I issue the following statement,
-----------------------------------------------
SQL> update scott.emp set sal = 0 ; -- Statement which fires trigger
SQL> commit;
Which fires the the following trigger,
----------------------------------------------
create or replace trigger scott.test_trigger
before update on scott.emp
begin
/*Code to store the SQL statement which fired the trigger */
insert into EMP_UPDATE_SQLS values ( **TRIGGERING_SQL_STMT** );
end;
Result expected:
---------------------
A row in EMP_UPDATE_SQLS , with the sql statement that fired the trigger, ( a row with the value 'update scott.emp set sal = 0' ).
Is it possible ???
Yes.
If you compare the fields between the :OLD and :NEW meta rows. the columns that are different are the ones that changed, assuming an update statement.