Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to stop an error from returing to the app

Author  Topic 

btrimpop
Posting Yak Master

214 Posts

Posted - 2001-12-06 : 11:41:36
Is there a way to keep an error from being returned to the client app. I have a Delphi program that calls a stored procedure. If the stored procedure errors I simply want to return a result set of zero to the app, not a database error exception. Currently I'm getting a "General SQL Error" message popping up on the client.

Thanks

"In theory there is no difference between theory and practice. But in practice there is!"



robvolk
Most Valuable Yak

15732 Posts

Posted - 2001-12-06 : 12:21:13
Adding this to the end of your sproc (before a RETURN statement, if you have one) should do it:

IF @@ERROR<>0
BEGIN
SELECT 0 AS Rows
END
RETURN


If it errors out, you'll get a 1 row recordset:

Rows
0

Go to Top of Page

btrimpop
Posting Yak Master

214 Posts

Posted - 2001-12-06 : 12:36:25
Thanks Rob, I appreciate the answer, but I don't think that's the problem. Let me try to explain the problem better.

I have an Delphi app that I currently have no means of modifying to enable it to intercept SQLServer raised database errors. If the stored procedure that it calls runs into a problem SQLServer is automatically sending the database error (which can be viewed or changed using the Raiserror function) back to the client. As a result of the database error Delphi's default error handler (or maybe it's the BDE) is popping up a General SQL error message box on the client. The problem is not getting a 0 returned to the App, it's getting the Raised database error to not be returned (I think). Does this make any sense?

The question becomes can I suppress SQLServer from either raising the error or stop it from being passed on to the client?

Whew after all that I need a !!!

"In theory there is no difference between theory and practice. But in practice there is!"



Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-06 : 12:49:15
If the stoerd procedure is doing the reaiserror itself then you can just remove it. If not then there is probably nothing you can do about it.
You cannot trap all errors anyway because there are some where sql server will terminate the batch and return directly to the client.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

btrimpop
Posting Yak Master

214 Posts

Posted - 2001-12-06 : 12:51:59
Thanks nr!

That's pretty much what I thought, but was hoping...

"In theory there is no difference between theory and practice. But in practice there is!"



Go to Top of Page
   

- Advertisement -