PL/SQL Trigger 4 – BEFORE and AFTER DELETE Trigger

BEFORE DELETE Trigger

A BEFORE DELETE Trigger means that Oracle will fire this trigger before the DELETE operation is executed.

The syntax for an BEFORE DELETE Trigger is:

CREATE or REPLACE TRIGGER trigger_name
BEFORE DELETE
   ON table_name
   [ FOR EACH ROW ]

DECLARE
   — variable declarations

BEGIN
   — trigger code

EXCEPTION
   WHEN …
   — exception handling

END;

Restrictions

    * You can not create a BEFORE trigger on a view.
    * You can update the :NEW values.
    * You can not update the :OLD values.

 

AFTER DELETE Trigger

An AFTER DELETE Trigger means that Oracle will fire this trigger after the DELETE operation is executed.

The syntax for an AFTER DELETE Trigger is:

CREATE or REPLACE TRIGGER trigger_name
AFTER DELETE
   ON table_name
   [ FOR EACH ROW ]

DECLARE
   — variable declarations

BEGIN
   — trigger code

EXCEPTION
   WHEN …
   — exception handling

END;

Restrictions

    * You can not create an AFTER trigger on a view.
    * You can not update the :NEW values.
    * You can not update the :OLD values.


You can leave a response, or trackback from your own site.

Leave a Reply