October 21, 2016 at 4:12 am
I have a proc whose structure is as below:
Create Proc
As
Begin
Insert Statement................... ( which calls insert trigger)
...
...( rest of the code )
...
END
If the Insert Statement Succeeds in inserting data but trigger produces an exception, then the rest of the code in the Proc will execute or not?
October 21, 2016 at 4:17 am
RAKSHITHA (10/21/2016)
I have a proc whose structure is as below:Create Proc
As
Begin
Insert Statement................... ( which calls insert trigger)
...
...( rest of the code )
...
END
If the Insert Statement Succeeds in inserting data but trigger produces an exception, then the rest of the code in the Proc will execute or not?
If the trigger fails, the insert will roll back.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 21, 2016 at 4:19 am
Does the exception in the trigger raise an error message? What is its severity number?
John
October 21, 2016 at 5:49 am
My code is as below. I know that when the trigger raises an error the inserted row is reverted but after that, whether the execution of rest of the code continues or terminates the proc batch.
October 21, 2016 at 6:00 am
Your error has severity 16 - that will only abort the current statement, which means that your batch will continue to run after the error. Higher level errors (19 and above, I believe) will abort the batch, while errors that are higher still (I can't remember what the threshold is) will abort the connection.
John
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply