p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Database > Oracle
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 11th, 2007, 01:10 AM
Registered User
 
Join Date: Apr 2007
Location: lahore, , Pakistan.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default triggers

what is the difference b/w statement level and row level triggers.i have a confusion in understanding the difference, because in my openion, e,g if we have made a statment level trigger in such a way that it should be fired when we insert a row in a table, n i think that, if we insert, for example 10 rows in the table, then the trigger will be fired 10 times, but our teacher told that the row level trigger is fired only once.In the case of a row level trigger, our teacher told that it is fired as many times as there are rows in a table, n if we are inserting 10 rows in a table, then it will be fired 10 times, as was the satement level trigger, then what is the diference b/w them?.please give examples

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 11th, 2007, 06:19 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hii,
got some document on triggers, hope this explains ur query...

A row level trigger is defined using the clause for each row. If this clause is not given, the trigger is assumed to be a statement trigger. A row trigger executes once for each row after (before) the event. In contrast, a
statement trigger is executed once after (before) the event, independent of how many rows are affected by the event. For example, a row trigger with the event specification after update is executed once for each row affected by the update. Thus, if the update affects 20 tuples, the trigger is executed 20 times, for each row at a time. In contrast, a statement trigger is only executed once.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old June 29th, 2007, 08:29 AM
Friend of Wrox
Points: 622, Level: 9
Points: 622, Level: 9 Points: 622, Level: 9 Points: 622, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2004
Location: India.
Posts: 220
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

does it mean tht Statement Triggers are only for Update & Delete statements???

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 7th, 2007, 03:17 AM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: Kampala, , Uganda.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not necessarily that statement triggers are for update and delete statements, but as explained above, statement triggers i think are invoked once for the entire sequence of statements bundled together while the row level are fired each time any turple is affected.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old October 18th, 2007, 09:17 AM
Authorized User
 
Join Date: Oct 2006
Location: Mumbai, , India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes,the statement level trigger fired when the seuqence of mentioned operations(in block) is completed e.g within a block u are inserting,updating ,deleting etc records, for all operations single statement level trigger will be fired,but in case of row level trigger,whenever a row operation is done,updated or inserted
etc,it will be fired by database everytime.

With thanks
rajesh,
India
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old April 9th, 2009, 05:25 PM
Authorized User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: New Delhi, Delhi, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

hi..!

if u issue an insert commondvlike
Code:
insert into emp1(fname,lname)
select fname,lname from emp2;
the select statement will return all the rows from table emp2, that will be inserted in table emp1. if u have an statement level trigger, it will be fired only ones irrespective of no. of rows being inserted.
if the trigger is on row level, it will be fired for each row being inserted to emp1.

the default is statement level. if u wanna a trigger on row level, u have to tell it explicitly as follows..
Code:
create trigger MY_TRG
after insert
on emp1
FOR EACH ROW
if u ommit FOR EACH ROW it would be an statement level trigger.

-- AKHIL
__________________
Akhil
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Triggers? odezzie Classic ASP Databases 1 March 28th, 2007 07:09 PM
Triggers mrookey SQL Server 2000 2 October 24th, 2006 08:11 AM
Triggers? prabodh_mishra Oracle 2 March 30th, 2006 05:51 AM
I need help with Triggers ravs BOOK: Professional SQL Server 2000 Programming 0 March 20th, 2006 04:59 PM
Triggers shahchi1 SQL Server 2000 1 November 1st, 2004 06:28 PM



All times are GMT -4. The time now is 02:57 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc