Subject Re: [ib-support] Stored Procedure with return value
Author Helen Borrie
At 03:06 PM 16-02-02 -0800, you wrote:
>Hi All,
>
>I want to make a stored procedure which return values, so I can use the returned value as input parameter for other procedure.
>I've already tried this one,
>
>set term ^;
>create procedure A
>(param1 char(8))
>returns(retparam1 numeric(5))
>as
>begin
> if (param1='GOOD' ) then
> retparam = 100;
> else
> retparam = 0;
>
> execute procedure B(:retparam);
>end ^
>set term ;^
>
>but when I executed it, it was return null values...
>
>Can anyone tell me how to make the right one..?

Try this:
set term ^;
create procedure A
(param1 VARchar(8))
returns(retparam1 numeric(5,0))
as
DECLARE VARIABLE retparam smallint;
begin
if (param1='GOOD' ) then <--- if you use char(8) test for 'GOOD '
retparam = 100;
else
retparam = 0;

execute procedure B(:retparam) RETURNING_VALUES(retparam1);
end ^
set term ;^

Helen


All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________