Friday, February 24, 2012

Error checking.

Forgive me for what maybe a dumb question, am fairly new to SQL. I see
a lot of code like this in stored procs:
update SomeTable
set ThisField = 'This'
where ThatColumn = 'That'
select @.intError = @.@.ERROR
if @.intError <> 0 begin
print 'error'
return
end
What is the point of error checking here?
If the Update statement fails, won't the stored proc bomb and raise an
error and the code will path will never hit the error checking code anyway?
Thanks> What is the point of error checking here?
> If the Update statement fails, won't the stored proc bomb and raise an
> error and the code will path will never hit the error checking code
> anyway?
A good start is Erland's site - check the links for error handling
http://www.sommarskog.se/|||A stored procedure doen not always stop the whole execution, only error
with a special severity level will stop the execution promptly. Erlands
error explanation is a goodd starting point for you.
HTH, jens Suessmeyer.

No comments:

Post a Comment