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
|