Subject Re: [firebird-support] Selectable sored procedure and SP inside it
Author Helen Borrie
At 11:46 PM 20/09/2004 +0300, you wrote:
>How to put inside a selectable Stored Procedure another Stored Procedure?
>I have following procedure. problem here is that only one row is
>returned from there (there is suppose to be lot more). What may be wrong
>here?
>
>CREATE PROCEDURE sp_toopaev_tunnid
>RETURNS(
>fkood VARCHAR(10),
>isikid VARCHAR(11),
>too_tegevus VARCHAR(2),
>algus date,
>lopp date,
>tootatud_oosel double precision,
>tootatud_paeval double precision,
>tootatud_ohtul double precision)
>AS
>BEGIN
>for select fkood, isikid, too_tegevus, algus, lopp from v_toopaev into
>:fkood, :isikid, :too_tegevus, :algus, :lopp
>DO


OK, what follows inside this block is executed once for each row returned
to the procedure by the FOR SELECT statement.

Assuming your inner procedure returns a single set of values, make this
inner procedure an executable one (no SUSPEND). Then, execute the inner
procedure and use RETURNING_VALUES to receive its output into your local
variables:

BEGIN
>/* select */

EXECUTE PROCEDURE SP_TOOPAEV_TUNDE(:algus, :lopp)
RETURNING_VALUES (:tootatud_oosel, :tootatud_paeval, :tootatud_ohtul);

END

SUSPEND;
>END

./heLen