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 09, 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: Saturday, May 04, 2013 11:13 AM
Points: 9,855, Visits: 9,374
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: Wednesday, May 15, 2013 3:49 PM
Points: 190, Visits: 636
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, March 26, 2013 8:41 AM
Points: 2,562, Visits: 3,451
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----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
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, February 21, 2013 12:31 PM
Points: 31, Visits: 98
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: Saturday, May 04, 2013 11:13 AM
Points: 9,855, Visits: 9,374
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: Wednesday, May 15, 2013 3:49 PM
Points: 190, Visits: 636

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