Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 14th, 2005, 03:51 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Triggers (1 table)

I'm using a trigger on insert (Table1) (i.e. 300 records) to insert records into table2 used for reporting. On the same table (table1) I have another trigger on insert that will calculate a value & insert that value along with some other field values into table3. Is there a way to only fire the 2nd trigger on table1 upon completion of the first trigger on table1. For example, on the first insert to table1 there are 300 records. Does trigger 2 fire when all the records inserted to table1 are copied to table2? or does it fire after each record is inserted. I need trigger 2 to only fire after all 300 records are finished processing on table2.

Comments.

 
Old June 14th, 2005, 03:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

if you always want to fire trigger 2 after trigger 1... why not use the same trigger to do the two things?? once you finish with trigger 1 code, execute trigger 2 code...

HTH

Gonzalo
 
Old June 14th, 2005, 04:21 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well, will that ensure that all the records inserted into the first table are processed?

 
Old June 14th, 2005, 04:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

the trigger will fire for every insert statement you execute.. if you just execute one for the 300 records it will execute only once.. if you execute 300 inserts it will execute 300 times, but the code for the second one will execute after the code for the first one always...

HTH

Gonzalo
 
Old June 14th, 2005, 04:36 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your prompt response. Very much appreciated.
The process that is inserting the records to table1 is being done behind the scene. So it appears that the trigger is firing for each record. Is there a way to execute a trigger or some other means (UDF, sproc)to execute trigger2. Maybe the logic i'm using is wrong.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to search db for all triggers and list SQL tcarnahan SQL Server 2000 1 September 1st, 2008 10:42 AM
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
difference between row n table level triggers Hafiz Muhammad Mushtaq Oracle 1 July 9th, 2007 12:48 AM
SQL Server Transactional Replication with Triggers RRNP SQL Language 0 October 4th, 2004 05:18 PM
SQL Server Transactional Replication with Triggers RRNP SQL Language 0 October 4th, 2004 05:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.