On Oct 15, 11:26 am, Subind <subind... at (no spam) gmail.com> wrote:
Hi,
I have these two procs and I'm trying to catch the error number from
the proc "call_error".
But I always get 0 as the value. It may be bcoz of the "return 0" stmt
at the end of proc "throw_error" (as it executed successfully).
I cannot change the proc throw_error. So is there a way to capture the
error value from proc "call_error"?
Appreciate any help.
drop proc throw_error;
create proc throw_error
as
begin
raiserror 500000 "Oops here is the error!!!"
return 0
end
create proc call_error
as
begin
declare at (no spam) rc int, at (no spam) er int
exec at (no spam) rc = throw_error
select at (no spam) er = at (no spam) at (no spam) error
print "Return: %1!, Error: %2!", at (no spam) rc, at (no spam) er
end
exec call_error
Thanks.
Hi Subind
Raiserror statement doesn't stop the batch execution, it just merely
displays user-defined error message and sets at (no spam) at (no spam) error variable. You can
verify it by adding "select at (no spam) at (no spam) error" after your raiserror statement.
From call_error point of view, throw_error finishes successfully, so
the behavior you have observed is expected. See this link for other
possible options:http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc32300...
Hope it helps
Leonid
Gvirtzhttp://www.gvirtz-consulting.com