How to Combine Insert, Update, and Delete in the same `Instead Of` Trigger, in Oracle db? When creating an Instead Of trigger, Sql Developer allows to include all 3 DML actions in the same trigger:



The result SQL looks like:

CREATE OR REPLACE TRIGGER TRIGGER1 
INSTEAD OF DELETE OR INSERT OR UPDATE ON PO_COSTED_BOM_V 
BEGIN
  NULL;
END;


I'm able to combine Insert and Update like this:

CREATE OR REPLACE TRIGGER TRIGGER1 
INSTEAD OF INSERT OR UPDATE OR DELETE ON PO_COSTED_BOM_V 
BEGIN
  UPDATE SRC_TBL SET CFG_VALUE = :NEW.CFG_VALUE
  WHERE CFG_NAME = :NEW.CFG_NAME;
  IF SQL%NOTFOUND THEN
      INSERT INTO SRC_TBL (CFG_NAME, CFG_VALUE) 
         VALUES(:NEW.CFG_NAME, :NEW.CFG_VALUE);
  END IF;
END;



But how do i get the Delete statement into the trigger? 
How does the trigger know which DML action was executed?


thx
From Coding the Trigger Body 


  Detecting the DML Operation that Fired a Trigger
  
  If more than one type of DML operation can fire 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 statement fire the trigger.
  
  Within the code of the trigger body, you can execute blocks of code
  depending on the kind of DML operation that fired the trigger:

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



in your case 

...
if inserting then

INSERT INTO SRC_TBL (CFG_NAME, CFG_VALUE) 
         VALUES(:NEW.CFG_NAME, :NEW.CFG_VALUE);

elsif updating then

 UPDATE SRC_TBL SET CFG_VALUE = :NEW.CFG_VALUE
  WHERE CFG_NAME = :NEW.CFG_NAME;

elsif deleting then

 ...

END IF;