Subject Re: [firebird-support] Re: Output Parameter
Author Helen Borrie
At 05:51 AM 30/01/2007, you wrote:
>--- "MILAN BABUSKOV" MILANB@... replied ---
> >
> > --- You wrote:
> > > CREATE PROCEDURE SERIALY (
> > > SCHL Varchar(5),
> > > YAR Varchar(4) )
> > > RETURNS (
> > > VAL Smallint )
> > > AS
> > > ...
> > >
> > > I have keep getting error on EXECUTE PROCEDURE serialy
> > ('0404','2007') RETURNING_VALUES (:VAL). The error message is
> > Try:
> > select VAL
> > from serialy ('0404','2007');
>
>Thanks. It worked. But has the syntax changed? I mean doesn't
>'EXECUTE PROCEDURE name (x,y) RETURNING_VALUES' work again?

It has never been valid in DSQL syntax - it is a PSQL extension that
is used when executing a SP inside another SP or a trigger. And your
syntax would be invalid for that usage also if you did not have a
variable declared into which it would be read. Here's how it is used:

create procedure aProc (...)
as
declare retval smallint;
begin
....
EXECUTE PROCEDURE serialy ('0404','2007')
RETURNING_VALUES (:retval)
....
end

If your procedure performed some DML then I don't recommend Milan's
solution. As defined, it would not return any value. Stick with
EXECUTE PROCEDURE and read the return value from the SPB. (You don't
say what your programming environment is so I can't expand on what
your interface provides to surface the SPB...)

If the SP only reads data without modifying anything, then use
Milan's suggestion but alter your proc to include a SUSPEND statement
after you have got the value for the return argument.

./heLEn