6.3. Insert Row Trigger Syntax

The Insert Row trigger has the following syntax.

CREATE OR REPLACE TRIGGER trigger_name
AFTER|BEFORE INSERT ON table_name
FOR EACH ROW
[WHEN (Boolean expression)]
DECLARE
    Local declarations
BEGIN
    Trigger Body written PL/SQL
END;

TRIGGER_NAME

Use trigger names that identify the table name and trigger type. A PL/SQL run time error will generate a PL/SQL error message and reference the trigger name and line number. The following Oracle error indicates that Line 5 in the AFTER-INSERT row trigger, on the STUDENTS table, has a divide-by-zero error.

ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.STUDENTS_AIR", line 5
ORA-04088: error during execution of trigger
  'SCOTT.STUDENTS_AIR'

The counting of line numbers ...

Get Programming Oracle® Triggers and Stored Procedures, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.