PL SQL Tutorial

PL SQL Triggers

    PL SQL Triggers are named stored procedures in the Database.But Associated with Events. Events can be DML Operations or DDL Operations. Using Traiggers all operations on the database can be captured and can be recorded, and also Complex Data Validations can be done using triggers. Apart from that Security check ,Auditing,logging etc. can be done using Triggers.

PL/SQL Triggers can be
  • DML Events
  • Compound DML Events
  • DDL Events
  • Database Events

Triggers can be enabled or disabled.

DML Events

DML Triggers are fired when DML operations are performed. INSERT
UPDATE DELETE There 2 types of DML triggers 1.Statement Level Trigger 2.Row Level Trigger

pseudo columns in triggers
  • :new
  • :old

:new and :old pseudo columns are of type %ROWTYPE. each field accessed using . operator, it should precede with :, for INSERT :old is not valid for DELETE :new is not valid for UPDATE :new and :old columns are used.

Conditional Predicates

Triggers use conditional predicates to detect triggering statement

UPDATING ('column')