December 15, 2008 at 3:32 am
Hi,
My procedures are used by front end.
If my procedure gets any error while executing, I want pass that error description to front end.
How this can be achieved?
Means I want to add proper error handler to my application. which is suitable for me.
pls help in this.
Regards
Bhusahn
December 15, 2008 at 3:36 am
with sql 2005 you can use try catch blocks for error handling, and then pass the error number and message back to the developer.
December 15, 2008 at 6:10 am
Also, by default, every proc exits with either a 0 for success or a 1 for failure as a return code on the proc. You can check for this in the calling application. For more on error handling in TSQL: http://www.simple-talk.com/sql/t-sql-programming/sql-server-error-handling-workbench/[/url]
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 17, 2008 at 12:37 am
steveb (12/15/2008)
with sql 2005 you can use try catch blocks for error handling, and then pass the error number and message back to the developer.
You know, I have to admit that I learned something today. I know about Try..Catch in ASP.NET but never knew I could use it in SQL as well. I am used to this type off error handling:
begin transaction
insert sometable(field1, field2)
values(1,2)
if @@error <> 0
begin
raiserror('Failed to insert',16,1)
rollback transaction
return(0)
end
commit transaction
The Try..Catch is a much better way of error handling and I can control the way the error gets back to the frontend application. Nice solution.
:-PManie Verster
Developer
Johannesburg
South Africa
I can do all things through Christ who strengthens me. - Holy Bible
I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply