Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 April 25th, 2008, 08:06 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to debbiecoates
Default Instead of triggers

hello

i am using a view to view/edit data in a datagrid in vb.

because the view is made up of more than one table, i am using an INSTEAD OF UPDATE trigger on my view, to update the table i want to update. Which is working great, But i get an error when i try to delete a record. I know that I can write an INSTEAD OF DELETE trigger, but can a view have more than one trigger?

for instance, if I needed to append, update and delete using this view, would I have to write a trigger, so that would be three in total, or could i use one trigger to do it all? and if I could use one trigger, how could i make it see which action it needs to perform, ie add, update, delete?

I would be grateful for any answers, or any links to information on the net, I've been surfing for this for the past few days, and cant find a page that deals with all three eventualities. Many Thanks, Debbie

 
Old April 25th, 2008, 10:36 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm pretty sure you can have multiple triggers fire on the same view. you can absolutely do it on a table. A potential problem there is that you can't specify which order the triggers fire in when you have more than one. However if you specify one On Insert, one On Update, and one On Delete trigger you won't have this problem as different events will fire each one.

In your case you should be able to write an additional instead of trigger for Deletes that will fire only when you delete a row from the view.

 
Old April 28th, 2008, 02:45 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to debbiecoates
Default

Great, Thank You






Similar Threads
Thread Thread Starter Forum Replies Last Post
Triggers? odezzie Classic ASP Databases 1 March 28th, 2007 06:09 PM
Triggers mrookey SQL Server 2000 2 October 24th, 2006 07:11 AM
Triggers? prabodh_mishra Oracle 2 March 30th, 2006 05:51 AM
Triggers shahchi1 SQL Server 2000 1 November 1st, 2004 06:28 PM





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