PL/SQL Triggers
PL/SQL triggers are block structures and predefined programs invoked automatically when some event occurs. They are stored in the database and invoked repeatedly in a particular scenario. There are two states of the triggers, they are enabled and disabled. When the trigger is created it is enabled. CREATE TRIGGER statement creates a trigger. A triggering event is specified on a table, a view, a schema, or a database.BEFORE and AFTER are the trigger Timing points.DML triggers are created on a table or view, and triggers. Crossedition triggers are created on Edition-based redefinition. System Triggers are created on schema or database using DDL or database operation statements.It is applied on new data only ,it don’t affect existing data.
They are associated with response-based events such as a
- Database Definition Language statements such as CREATE, DROP or ALTER.
- Database Manipulation Language statements such as UPDATE, INSERT or DELETE.
- Database operations such as LOGON, LOGOFF, STARTUP, and SHUTDOWN .
PL/SQL Triggers
PL/SQL stands for Procedural Language/ Structured Query Language. It has block structure programming features.PL/SQL supports SQL queries. It also supports the declaration of the variables, control statements, Functions, Records, Cursor, Procedure, and Triggers.PL/SQL contains a declaration section, execution section, and exception-handling section. Declare and exception handling sections are optional.
Syntax:
Declaration section
BEGIN
Execution section
EXCEPTION
Exception section
END;