Catching exceptions.
Posted in 1999
Topics: Stored Procedures & SPL
How can i catch the errorcode and text of an exception? I must use SET
clause, but I can't find any example. I would like doing something like
this:
create procedure procname()
on exception
-- take the errorcode in var A, text in var B
do something
-- re-raise the exception
raise exception A,0,B;
end
...
end procedure;
Hi,
try something like this:
try {
...
}
catch (<Name>Exception exc) {
String varA = exc.getMessage ();
...
throw new <Name>Exception (varA, ...);
}
<Name> = kind of exception, you are using.
... depends also on the kind of exception you are processing.
You can find the methods of the standard exceptions in the
description of Throwable because Exception is inherited from
it. Hope that will help you.
regards
Jo
In article <370E0859.7311B258@uco.es>,
Aurelio <i52sacaa@uco.es> wrote:
> How can i catch the errorcode and text of an exception? I must use SET
> clause, but I can't find any example. I would like doing something like
> this:
>
> create procedure procname()>
> on exception
> -- take the errorcode in var A, text in var B
> do something
> -- re-raise the exception
> raise exception A,0,B;
> end
> ...
>
> end procedure;
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
I think there are some mixed thoughts here.
The original question is about SPL, Informix's stored procedure
language,
but the answer is given in java, Sun's platform-independent language !
The correct answer (in SPL) would be:
CREATE PROCEDURE ...
DEFINE SQLerr int
DEFINE ISAMerr int
DEFINE ERRinfo CHAR(72)
ON EXCEPTION SET SQLerr, ISAMerr, ERRinfo
-- Do any number of things
RAISE EXCEPTION SQLerr, 0, ERRinfo
END EXCEPTION
-- your code here
END PROCEDURE
Regards
Paulo
pichler@networkers.de wrote:
>
> Hi,
>
> try something like this:
>
> try {
> ...
> }
> catch (<Name>Exception exc) {
> String varA = exc.getMessage ();
>
> ...
>
> throw new <Name>Exception (varA, ...);
> }
>
> <Name> = kind of exception, you are using.
> ... depends also on the kind of exception you are processing.
> You can find the methods of the standard exceptions in the
> description of Throwable because Exception is inherited from
> it. Hope that will help you.
>
> regards
> Jo
>
> In article <370E0859.7311B258@uco.es>,
> Aurelio <i52sacaa@uco.es> wrote:
> > How can i catch the errorcode and text of an exception? I must use SET
> > clause, but I can't find any example. I would like doing something like
> > this:
> >
> > create procedure procname()> >
> > on exception
> > -- take the errorcode in var A, text in var B
> > do something
> > -- re-raise the exception
> > raise exception A,0,B;
> > end
> > ...
> >
> > end procedure;
> >
> >
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
____________________________________________________________
Paulo Silva mailto:psilva@informix.com
Consultant/Trainer phone : +351 1 412 89 40
Informix Software Portugal fax : +351 1 410 84 37
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯