Subject Re: [firebird-support] Re: Exception hangling in stored procedure
Author Michael Ludwig
tomkrej schrieb am 29.11.2010 um 08:23 (-0000):
> Hi, the code loked like this
>
> create procedure test_dostupnost (....)
> returns (je_dostupny smallint)
> begin
>
> je_dostupny = -1;
> execute procedure over_dostupnost_sklad(...);
> execute procedure over_dostupnost_obchod(...);
> ...
>
> je_dostupny = 1;
> suspend;
>
> when exception exc_nedost_sklad do
> je_dostupny = -2;
> when exception exc_nedost_obchod do
> je_dostupny = -3;
> ...
>
> end
>
> As I found in some exemple code. And it did not work (it returns empty
> dataset)

Presumably because it jumps from the place where you raise the exception
straight to the WHEN handler without SUSPEND getting a chance to put the
data in the output slot or whatever it is called.

> But after Your message I tried to enclose this code into the begin ..
> end block and the suspend command after that block and, now it works.
>
> begin
> begin
> execute ...
> when ....
> end
>
> suspend;
> end

What exactly is the rule for the placement of WHEN exception handlers?

From experimentation I suspect they must not be followed by anything,
apparently with the exception of SUSPEND.

--
Michael Ludwig