SQL-Triggers-Page22
πWhat are Database Triggers?
Database triggers are procedures that are implicitly executed by the Oracle engine when an insert, update, or delete is issued against a table (from SQL editor or through an application). These procedures are called database triggers.
When a trigger is fired, a SQL statement inside the trigger's PL/SQL code block can also fire the same or some other trigger. This is called cascading trigger.
Difference between Triggers and Procedures:
1)Triggers do not accept parameters whereas Procedures can.
2)A trigger is executed implicitly by the Oracle engine itself upon modification of an associated table or its data. Whereas to execute a procedure, it has to be explicitly called by a user.
A trigger has three basic parts:
1)A triggering event or statement
2)A trigger restriction
3)A trigger action
✅Triggering Event:
It is a SQL statement that causes a trigger to be fired. It can be Insert, Update or Delete statement for a specific table.
✅Trigger Restriction:
A trigger restriction specifies a boolean expression that must be true for the trigger to fire.
✅Trigger Action:
A trigger action is the PL/SQL code to be executed when triggering statement is encountered and any trigger restriction evaluates to true.
Comments
Post a Comment