dbTalk Databases Forums  

raiserror

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss raiserror in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
poptcat
 
Posts: n/a

Default raiserror - 09-25-2009 , 09:20 AM






Hi.
I call raiserror with a custom message. Does anyone knows how to
capture it ?
For example -
----
raiserror 21000 ....
----
exception
when others
if sqlcode=21000
delete mytable;
resignal;
end if
end

In this case delete mytable removes my error and resignal does
nothing.

Any solution?

Gabriel Popa

Reply With Quote
  #2  
Old   
Nick Elson [Sybase iAnywhere]
 
Posts: n/a

Default Re: raiserror - 09-28-2009 , 06:04 PM






Your nesting and mixing different syntax.
The Raiserror syntax is Transact SQL,
the 'EXCEPTION WHEN OTHERS' construct
is WSQL and is more associated with the SIGNAL
mechanism.

Raiserror combines some of the features of SIGNAL
and the MESSAGE statement. You thiould maybe
have coded your

raiserror 21000 '.....%1....', <variable>;

as
declare my_exception EXCEPTION FOR SQLSTATE '21000';
. . .
message string( '......',<variable>,'....');
signal my_exception ;

Of course the client needs to be able to pick that message up.

If you need to continue with the use of the RAISERROR
statement then switching to the `if @@error` mechanism
is the T/SQL way....






"poptcat" <poptcat (AT) gmail (DOT) com> wrote

Quote:
Hi.
I call raiserror with a custom message. Does anyone knows how to
capture it ?
For example -
----
raiserror 21000 ....
----
exception
when others
if sqlcode=21000
delete mytable;
resignal;
end if
end

In this case delete mytable removes my error and resignal does
nothing.

Any solution?

Gabriel Popa

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.