Ticker

6/recent/ticker-posts

PL/SQL - TRIGGERS IN PL/SQL

TRIGGERS IN PL/SQL

TRIGGERS IN PL/SQL

The literal meaning of the word "Trigger" is to activate. Triggers are simply stored procedures that are ran automatically by the database whenever some event (usually a table update) happens. 

"A Trigger is a stored procedure that defines an action that the database automatically initiates when some database-related event such as INSERT, UPDATE or DELETE occurs." 

Thus the triggers are basically PL/SQL procedures that are tables, and are called whenever a certain modification (event) modification statements may include INSERT, UPDATE, and

Syntax:

CREATE [OR REPLACE] TRIGGER trigger_name BEFORE (or AFTER) INSERT OR UPDATE [OF COLUMNS] OR DELETE ON table name [FOR EACH ROW [WHEN (condition)]] BEGIN.

...

END;

By the usual CREATE OR REPLACE the TRIGGER specifies just what type of object is being created.

The BEFORE (or AFTER) in the trigger definition refers to when one wants to run the trigger, either before the actual database modification (update, delete, insert) or after.