Help on triggers

I have a table (TableA). In this table, I create a trigger that inserts a row into another table (TableB) to insert, update, and delete actions performed in TableA. My intention is to track the modification on TableA.

I have the only trigger to do this. (create a trigger name for the trigger before inserting or updating or deleting it on TableA ... - View).

Now I need the actual operation performed in Table A. When the trigger inserts a row into TableB, I want the actual operation performed on TableA to also be inserted into the column.

Is there any way to capture what operation is performed in TableA with one trigger, or do I need to create a separate trigger for each operation of the DML operator?

TIA.

+3
source share
2 answers

Quote docs :

DML trigger trigger detection

If more than one type of DML operation can trigger a trigger (for example, ON INSERT or DELETE or UPDATE of emp), the trigger body can use the conditional predicates INSERTING, DELETING, and UPDATING to check which type of message the trigger fires.

In the trigger body code, you can execute blocks of code depending on the type of DML operation that triggers the trigger:

IF INSERTING THEN ... END IF;
IF UPDATING THEN ... END IF;
+4
source

In PL / SQL, you can use the following predicates:

IF INSERTING THEN ... END IF;
IF UPDATING THEN ... END IF;
IF DELETING THEN ... END IF;
0
source

All Articles