PL/SQL Trigger 3 – BEFORE and AFTER UPDATE Trigger

BEFORE UPDATE Trigger

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

The syntax for an BEFORE UPDATE Trigger is:

CREATE or REPLACE TRIGGER trigger_name
BEFORE UPDATE
   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 UPDATE Trigger

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

The syntax for an AFTER UPDATE Trigger is:

CREATE or REPLACE TRIGGER trigger_name
AFTER UPDATE
   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