Subject Re: [firebird-support] How to call a SP in another SP both with return parameters
Author Helen Borrie
At 04:35 PM 8/02/2005 +0000, you wrote:


>Hi,
>
>How do i call a SP in another SP both with return parameters.
>in SP1 i need to do something like this but i don't know the right
>syntax: ERRORTEXT = EXECUTE PROCEDURE SP2(AID);
>
>Greetings,
>Filip Moons
>
>
>CREATE PROCEDURE SP1 (ID INTEGER) RETURNS (ERRORTEXT VARCHAR(40))
>
>CREATE PROCEDURE SP2 (ID INTEGER) RETURNS (ERRORTEXT VARCHAR(40))

in SPI:

...
declare variable return_val varchar(40);
...
begin
aid = 99;
...
execute procedure SP2 (:aid)
returning_values (:return_val);
...

Or, if you're calling SP2 in a loop and you just want the returned value to
jump into SP's ERRORTEXT return value, just do this:

...
begin
FOR SELECT......
... into :aid, ............
DO
BEGIN
execute procedure SP2 (:aid)
returning_values (:errortext);
SUSPEND;
END
....
end

./hb