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 June 28th, 2004, 05:00 AM
Authorized User
 
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to deyakhatib
Default Triggers with views

Hi All,

I have a strange problem, when I define an after update trigger on a view I have a message saying:
 "Server: Msg 208, Level 16, State 4, Procedure after_update_tblpcl_AnalogValue_Minutely, Line 1"
although I am the owner of the view and its in my DB, but when I make the trigger as "Instead of Update" it works fine.

thanx for help.

PEACE!

 
Old June 28th, 2004, 09:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think you haven't posted the entire part of the error that you got. Can you post the remaining part of it too?

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old June 29th, 2004, 10:38 AM
Authorized User
 
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to deyakhatib
Default

Hi All,

Things mixed up in my mind, I cant create after update trigger on a view its restricted to tables only.

PEACE!

 
Old June 29th, 2004, 10:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

[u]SQL Server 2000's INSTEAD OF Triggers</u>
Restrictions
Anything good usually comes with some restrictions, and INSTEAD OF triggers are no exception. While you may have more than one FOR (now AFTER) trigger per triggering action, you may have only one INSTEAD OF trigger per triggering action on a given object. You can fake this, however, by creating a stack of views with each view being a SELECT * on the next view until the final view is a SELECT * of the base object. You then attach the INSTEAD OF triggers on each of the views, and all access is done through the topmost view.

There are also restrictions with respect to the use of INSTEAD OF triggers where cascaded DELETEs or UPDATEs have been put in place through DRI (declarative referential integrity). You can't have an INSTEAD OF trigger on a table with the corresponding CASCADE action, so there can be no INSTEAD OF DELETE when ON DELETE CASCADE is in effect. In other words, if you've created a table that has a FOREIGN KEY constraint with ON DELETE CASCADE, you can't create an INSTEAD OF DELETE trigger on that same table. The same restriction applies to INSTEAD OF UPDATE triggers and cascaded UPDATEs. If you attempt to create the trigger when the CASCADE option is in effect, the CREATE TRIGGER statement will fail. If you create the trigger first and then alter the table to add the FOREIGN KEY constraint with the CASCADE option, the ALTER TABLE statement will fail.


Inside SQL Server - INSTEAD OF Triggers

Trigger Limitations

Hope that helps
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using variables in Views Jimbocephus SQL Server 2005 8 March 14th, 2008 02:30 PM
Views prashar SQL Language 1 December 13th, 2005 02:10 AM
converting Access 2000 views to Sql views matta Classic ASP Professional 1 January 26th, 2005 03:37 PM
Views or not ?? stagedancer SQL Server 2000 1 November 24th, 2004 03:08 PM
Views SAM GORDON SQL Server 2000 5 July 19th, 2003 08:14 AM





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