Sorry if this has been asked before, seems the search is not responding to well today.
Anyways, ran into the following problem. I have a stored procedure and it contains a query that in some cases can result in an error (converts a character field to a numeric field). Now I remember that after the query I can check @@error to see if it failed and react to it in a peacefull manner. It now seems though Sybase just stops executing my stored procedure and doesn't let me to do any cleanup resulting from the fault.
I made a little test script to demonstrate my problem, hope someone can tell me how to do this correctly:
create table TMP_TEST (
TMP_CHAR varchar(250) null,
TMP_NUMBER numeric(15) null
drop procedure stp_test
create procedure stp_test as
declare @lasterror integer
insert TMP_TEST (TMP_CHAR, TMP_NUMBER) select "test",convert(numeric(15),"01abc")
if (@lasterror<>0) begin
declare @status integer
Unfortunately, you must take some measures to
avoid a conversion error. These errors are a different
kind than execution errors such as "duplicate key".
Instead, they are evaluated in an earlier stage by ASE,
and handled in a way closer to syntax errors than to
My advice: don't include statements prone to
conversion errors in stored procedures. Try to
isolate them in stand-alone SQL statements
whose errors are handled by your application.