Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Step1:- Start

Step2:- Create the trigger.


Ex:- create or replace TRIGGER {trigger_name}
INSERT OR
DELETE OR
UPDATE OF {column1,column2,..} ON {table_name} FOR EACH ROW

Step3:- Declare the columns to store the information which operation we have done on a table and what is the data.
Ex:-

V_COL_NAME ,V_TRIG_OPERATION ,V_OLD_VALUE ,


V_NEW_VALUE ,V_TABLE_NAME ,V_KEY_VALUE .

Step4:- Before inserting the values into the columns have to recognize which operation we are performing.
1) If the operation is INSERTING or DELETING then,
Ex:- IF (INSERTING() OR DELETING()) THEN
V_COL_NAME := 'ALL_COLUMNS';
V_NEW_VALUE := :NEW.COLUMN_NAME;
V_OLD_VALUE := :OLD. COLUMN_NAME;
2) If the operation is INSERTING then,
Ex:- IF updating('OBJECT_ID') THEN
V_COL_NAME := 'OBJECT_ID';
V_OLD_VALUE := :OLD. COLUMN_NAME;
V_NEW_VALUE := :NEW. COLUMN_NAME;
V_KEY_VALUE := :OLD. COLUMN_NAME;
Step5:-Create one procedure with params and insert the changed values in a table.
Ex: INSERT INTO table_name (table_col1, table_col2,) values (param1, param2 ,);
Step6:- END;

You might also like