Blog Detail

Execution order of Triggers in Oracle

25 Jan 11
admin
No Comments
Hi,

We can specify order of execution of triggers in oracle using FOLLOWS clause.

Example:

CREATE OR REPLACE TRIGGER trigger_follows_test_trg_1
BEFORE INSERT ON trigger_follows_test
FOR EACH ROW
FOLLOWS trigger_follows_test_trg_2
BEGIN
DBMS_OUTPUT.put_line(‘TRIGGER_FOLLOWS_TEST_TRG_1 – Executed’);
END;

Now the TRIGGER_FOLLOWS_TEST_TRG_1 trigger always follows the TRIGGER_FOLLOWS_TEST_TRG_2 trigger.

Result:

SQL> SET SERVEROUTPUT ON
SQL> INSERT INTO trigger_follows_test VALUES (2, ‘TWO’);
TRIGGER_FOLLOWS_TEST_TRG_2 – Executed
TRIGGER_FOLLOWS_TEST_TRG_1 – Executed

1 row created.

SQL>

Leave A Comment