Triggers:
What is triggers:Oracle lets you define procedures called triggers that run implicitly when an
Types of triggers:
What is triggers:Oracle lets you define procedures called triggers that run implicitly when an
INSERT
, UPDATE
, or DELETE
statement is issued against the associated table or, in some cases,
against a view, or when database system actions occur.Types of triggers:
- BEFORE INSERT Trigger
- AFTER INSERT Trigger
- BEFORE UPDATE Trigger
- AFTER UPDATE Trigger
- BEFORE DELETE Trigger
- AFTER DELETE Trigger
- BEFORE INSERT Trigger: A BEFORE INSERT Trigger means that Oracle will fire this trigger before the INSERT operation is executed.
Syntax
The syntax to create a BEFORE INSERT Trigger in Oracle/PLSQL is:CREATE [ OR REPLACE ] TRIGGER trigger_name BEFORE INSERT ON table_name [ FOR EACH ROW ] DECLARE -- variable declarations BEGIN -- trigger code EXCEPTION WHEN ... -- exception handling END;
Restrictions
- You can not create a BEFORE trigger on a view.
- You can update the :NEW values.
- You can not update the :OLD values.
0 comments:
Post a Comment