PL/SQL triggers
Triggers are SQL and PL/SQL blocks which are implicitly executed by Oracle when a INSERT, UPDATE
, or DELETE
statement is issued against the associated table. You cannot explicitly invoke a trigger; however, you can enable and disable a trigger.
A trigger has three basic parts:
Triggering event or statement: This can be a
INSERT, UPDATE
, orDELETE
statement on a tableTiming point: Determines whether the trigger fires before or after the triggering statement and whether it fires for each row that the triggering statement affects
Trigger action: This is the procedure that contains the SQL & PL/SQL statements and code to be run
There are two ways of firing a trigger. Firstly, fire the trigger once for the triggering statement irrespective of how many rows it affects and secondly, once for every row affected. A row trigger is fired for each row while a statement trigger is fired once on behalf of the triggering statement. For example, if the UPDATE
statement modifies five...