Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
   
Database Triggers




By Vishant Sanghavi
Oct 21, 2008

Digg! digg!     Print    email to friend Email to Friend

Note: This article was written for educational purpose only. Please refer to the related vendor documentation for detail.




Database Triggers

Database Triggers are one of the good features available in ORACLE. Database triggers are written on any table. There are 12 types of Database Triggers they are:

1. Before Insert
2. After Insert
3. Before Update
4. After Update
5. Before Delete
6. After Delete
7. Before Insert for each row
8. After Insert for each row
9. Before Update for each row
10. After Update for each row
11. Before Delete for each row
12. After Delete for each row

It will be get executed as soon as any DML operation take place on table. It will not get executed if user issues truncate command. Like procedures and functions no p-code (compile code) will not be available for database trigger in database. Each time trigger get executed ORACLE will compile trigger and generate p-code. Because of this some time performance of ORACLE will get affected. In trigger we can use: NEW. <Column name> and : OLD.<Column name> to get new and old value of table column. We can’t use: OLD in insert trigger. We can’t user: NEW in delete trigger.

Syntax of creating Database Trigger is

CREATE OR REPLACE TRIGGER <Trigger Name >

After/Before Insert/Update/Delete on <Table Name>

Reference New as New Old as Old <for Each Row

Declare

Declare required Variables

Begin

Body

End.

 



Comments/Reviews on this article:
Nakkeeran  k
May 18, 2010

it's helpful for beginners

 
About author:

 

Please login to post your comments





  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor