Re: Handle Informix exceptions in Delphi
Posted in 1998
I have just started a thread of the same problem. Here is an example of a
work around. Essentially, you need to allow for returning two more
parameters than originally desired. These additional parameters must be
checked for errors.
In this example I return two additional parameters, one the error number and
the other a message. I have also added a raise exception. This allows for
any existing database application that do see the exception to act
accordingly. The Delphi code you need to adjust to look at and evaluate the
expression allocated to the error trapping, in this case the last two, and
then raise an exception internally.
However, this does get more an more peculiar.
The example below, does have a 'foreach' in. Uncomment the foreach and run
the SP, Delphi does pick up the exception, but now, comment it out and see
what happens - Delphi does not trap the exception.
This example does run on the stores7 database.
drop procedure sp_test;
create procedure sp_test()
returning integer, -- data to return
integer, -- error no,
char(80); -- error message
define esql smallint; define eisam smallint;
define etext char(80);
define l_datacol integer;
on exception
set esql, eisam, etext
return null, esql, etext with resume;
raise exception esql, eisam, etext;
end exception
{
foreach select customer_num
into l_datacol
from customer
return l_datacol, 0, null with resume;
end foreach
}
-- FORCE an exception by placing a char in a integer!
-- you could also use the stored procedure's RAISE EXCEPTION
let esql = 'A';
end procedure;
grant execute on sp_test to public;
Dennis Harding
pavarkh@my-dejanews.com wrote in message
<6ljjca$p3m$1@nnrp1.dejanews.com>...
>I use Informix Workgroup server 7.1 and
>Delphi 3C/S (BDE v4.51). Delphi doesnt't catch exception,
>raised in Informix stored procedure (i call stored
>procedure both from TStoredProc and TQuery).
>However, Informix SQL Editor catch it.
>How i can handle this kind of exceptions in Delphi ?
>
>Besr regards,
>Pavel Archipov
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading