Re: SQL Errors in Stored Procedures
From: Greg Linwood (g_linwoodQhotmail.com)
Date: 04/24/04
- Next message: Louis Davidson: "Re: google search of this group"
- Previous message: oj: "Re: xp_cmdshell"
- In reply to: Zach Wells: "Re: SQL Errors in Stored Procedures"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 24 Apr 2004 13:06:02 +1000
T-SQL / SQL Server currently have no way of doing this.
Another option not yet suggested is to create a data access layer between
the app & SQL Server to provide such functionality.
Personally, I don't like Zach's idea of performing the lookup before doing
the insert as this can have large performance implications, even if the
check only seeks against the PK. I prefer to design applications so that
there's a very low possibility of key conflict & then handling exceptions on
the rare occassion rather than ensuring that every single insert suffers the
performance penalty of a lookup on the PK index. But then again, each to
their own!
Regards,
Greg Linwood
SQL Server MVP
"Zach Wells" <no_zwells_spam@ain1.com> wrote in message
news:%23sOdW3WKEHA.2776@TK2MSFTNGP12.phx.gbl...
> gb wrote:
>
> > Is there a way to "turn off" error messages in a stored procedure so
that they don't get sent to the calling procedure? I have a VB.NET app that
executes a stored procedure to insert some records. Currently, whenever you
try to insert a duplicate record, the stored procedure throws it back to the
VB.NET app as an exception. I would like to handle the error in the stored
procedure and return the error number instead of the exception being thrown.
I can save the @@error value in a variable and return it, but currently the
exception gets thrown also. I know I can handle the exception at the VB.NET
app level, but I would prefer to handle this in a more graceful way.
> >
> > Thanks for any help.
>
> Checking for the existence of the record prior to doing the insert would
> be the more graceful way of handling this situation.
>
> Zach
- Next message: Louis Davidson: "Re: google search of this group"
- Previous message: oj: "Re: xp_cmdshell"
- In reply to: Zach Wells: "Re: SQL Errors in Stored Procedures"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|