How to determine if you are deleting in a trigger.

  • Hello, is there an actual way to definitively tell if an insert, update or delete trigger was fired due to a delete?  In ORacle PL/SQL you can just do;

    IF DELETING THEN ....

     

    Thank you!

    Best Regards,

    ~David

  • This was removed by the editor as SPAM

  • Assumming that you have a single trigger on the table to handle inserts, updates and deletes there is a way to identify what caused the trigger to fire

    Use the tables inserted and deleted.

    Where there is only a row or rows in the inserted table it was an insert that fired the trigger

    Where there is only a row or rows in the deleted table it was a delete that fired the trigger

    Where there are rows in both inserted and deleted it was an update that fired the trigger

     

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply