Getting the value that triggered the Oracle trigger

I am very new to Oracle triggers. Suppose I have a trigger on an insert in an emp table. Is there any way to find out what was the inserted record that triggered the trigger. I wanted the trigger to have code that did something if the inserted record was a specific value.

+7
source share
2 answers

Assuming you have a level trigger, you can simply use a pseudo-record :NEW

 CREATE TRIGGER name_of_trigger BEFORE INSERT ON emp FOR EACH ROW DECLARE <<declare variables>> BEGIN IF( :new.ename = 'JUSTIN' ) THEN <<do something if the newly inserted ENAME value is 'JUSTIN'>> END IF; END; 

For a DDL trigger, the approach is completely different. In this case, the pseudo-functions ora_dict_obj_owner and ora_dict_obj_name will return the owner and name of the table in which the DDL operator operates.

+10
source
+7
source

All Articles