Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

doubt about triggers Expand / Collapse
Author
Message
Posted Monday, December 22, 2008 7:05 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Sunday, August 9, 2009 11:55 PM
Points: 24, Visits: 76

If i put a trigger which executes before some data is inserted/udpated into a table.
and if that trigger calls a function, which raises exception, will the insertion of data into the table will be succesfull or not ?
Post #624387
Posted Monday, December 22, 2008 9:57 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 11:52 AM
Points: 9,294, Visits: 9,484
That depends on what kind of error it is and whther you use TRY..CATCH.. to trap it or not.

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #624429
Posted Monday, December 22, 2008 10:01 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, June 25, 2013 9:13 PM
Points: 190, Visits: 637
I am wondering how you can write a trigger that would be fired before inserting/updating rows into a table.
If i am not wrong a trigger will fire either after or instead of the event that actually fired the trigger.

Regards,
Sam.
Post #624431
Posted Wednesday, December 24, 2008 12:17 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 21, 2014 2:36 AM
Points: 2,840, Visits: 3,970
Can u provide the trigger script and sample data from the table associated with that trigger...after that anyopne can porvide you better help :)

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #625208
Posted Wednesday, December 24, 2008 1:13 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, July 11, 2013 1:19 PM
Points: 31, Visits: 100
If you want "before" you must use "instead" and then perform the functions you want to do before the update/delete/insert is performed and then perform the update/delete/insert in code. That's how I understand it.
Post #625223
Posted Wednesday, December 24, 2008 8:08 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 11:52 AM
Points: 9,294, Visits: 9,484
samsqlserver (12/22/2008)
I am wondering how you can write a trigger that would be fired before inserting/updating rows into a table.
If i am not wrong a trigger will fire either after or instead of the event that actually fired the trigger.

Yes, you are correct Sam. The OP would have to use an INSTEAD OF trigger and then do the actual insert/update themselves.


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #625402
Posted Wednesday, December 24, 2008 1:35 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, June 25, 2013 9:13 PM
Points: 190, Visits: 637

Yes, you are correct Sam.
The OP would have to use an INSTEAD OF trigger and then do the actual insert/update themselves.


Thankyou. I just realized it.
It's all about improvising and using the same thing it in different ways.

Regards,
Sam.
Post #625567
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse