Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > SQL Server 2K - Trigger Calling Extended Stored Procedure


Reply
 
Thread Tools Display Modes
  #1  
Old 10-04-2004, 12:33 AM
Alvein's Avatar
Alvein Alvein is offline
Junior Contributor
 
Join Date: Aug 2002
Location: Iceland
Posts: 276
Smile SQL Server 2K - Trigger Calling Extended Stored Procedure


Hello,

I've installed a "For Update" trigger for some table that calls a extended stored procedure (ESP). In some cases, the ESP needs to modify the same table, maybe causing a recursive call of the trigger.

Is there a way to "disable" the trigger inside the code just before the operation that updates the table and "re-enable" it just after? I know I can disable recursive triggering at database level, but I'm developing a database add-on so I don't want to interfere with the existing triggers behavior (if any) for the rest of the tables.


10x.
Reply With Quote
  #2  
Old 10-04-2004, 12:41 AM
NEOLLE's Avatar
NEOLLE NEOLLE is offline
fully realized avatar

Super Moderator
* Expert *
 
Join Date: Jun 2004
Location: Davao Philippines
Posts: 2,295
Smile

Hello,
Im not sure this is possible. This causes mutating effect to the table.
Reply With Quote
  #3  
Old 10-04-2004, 11:08 AM
Alvein's Avatar
Alvein Alvein is offline
Junior Contributor
 
Join Date: Aug 2002
Location: Iceland
Posts: 276
Default

mutating??
Reply With Quote
  #4  
Old 10-04-2004, 11:33 AM
loquin's Avatar
loquin loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,378
Default

Try calling the sp_dboption stored procedure to disable direct recursion before you alter the table, and call it again afterwards to enable direct recursion. I haven't tried it myself, so I don't know if this will work or not.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
  #5  
Old 10-04-2004, 06:22 PM
NEOLLE's Avatar
NEOLLE NEOLLE is offline
fully realized avatar

Super Moderator
* Expert *
 
Join Date: Jun 2004
Location: Davao Philippines
Posts: 2,295
Smile

Quote:
Originally Posted by Alvein
mutating??
Is basically the effect doing updates/modification on a table with an active transaction. All in one procedure.
Reply With Quote
  #6  
Old 10-05-2004, 01:09 AM
Alvein's Avatar
Alvein Alvein is offline
Junior Contributor
 
Join Date: Aug 2002
Location: Iceland
Posts: 276
Default

Really, the recursion I get is a nested-type, so I would need to work at database level, which I don't want.

I've "solved" the problem by issuing "ALTER TABLE .... DISABLE TRIGGER ...." just before the ESP call, and "ALTER TABLE .... ENABLE TRIGGER ...." just after. It seems so simple, but I was thinking ALTER TABLE was forbidden inside a trigger definition.

However, I still wonder if there are side effects with this approach.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->