There are optional declaration and exception sections, like any other PL/SQL block, if required.
The "dml-event" can be one or more of the following.
Many applications update all of the columns in a table -- setting them to their old value, rather then trying to figure out exactly which columns have been updated by the client. create or replace trigger test_trigger 2 after update of x,y on test 3 for each row 4 begin 5 if updating( 'X' ) then 6 dbms_output.put_line( 'X is being updated' ); 7 end if; 8 9 if updating( 'Y' ) then 10 dbms_output.put_line( 'Y is being updated' ); 11 end if; 12 end; 13 / Trigger created.
Hello, I am not familiar with Oracle at all, but I find myself in a situation where I need to build a update trigger for one of our tables.
This trigger needs to update a tracking table anytime any of the fields get updated.
"WHERE 1 = 2" means: create a table with all columns as the original one, but make it empty (because no records satisfy "1 = 2" condition).
Add two more columns: action (I - insert, U - update, D - delete) and datum (timestamp which will tell us when something happened).