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:

  1. BEFORE INSERT Trigger
  2. AFTER INSERT Trigger
  3. BEFORE UPDATE Trigger
  4. AFTER UPDATE Trigger
  5. BEFORE DELETE Trigger
  6. AFTER DELETE Trigger
  1. 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:

Popular Posts

Blogger templates

Blogger news

Blogroll

Powered by Blogger.

Labels

Followers

Follow us on FaceBook