Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Development
»
doubt about triggers
doubt about triggers
Rate Topic
Display Mode
Topic Options
Author
Message
harish_ravi
harish_ravi
Posted Monday, December 22, 2008 7:05 PM
Grasshopper
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
RBarryYoung
RBarryYoung
Posted Monday, December 22, 2008 9:57 PM
SSCrazy 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
UnionAll
UnionAll
Posted Monday, December 22, 2008 10:01 PM
SSC-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
Bhuvnesh
Bhuvnesh
Posted Wednesday, December 24, 2008 12:17 AM
SSCrazy
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
nico van niekerk
nico van niekerk
Posted Wednesday, December 24, 2008 1:13 AM
SSC 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
RBarryYoung
RBarryYoung
Posted Wednesday, December 24, 2008 8:08 AM
SSCrazy 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
UnionAll
UnionAll
Posted Wednesday, December 24, 2008 1:35 PM
SSC-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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.