Subject Re: Problem when returning values with EXECUTE STATEMENT
Author aalliana
Thanks Helen,

BTW, I'm using Firebird 2.1.1


When I add the "returning_values" keyword to the dsql I get a syntax
error (on execution). ie.

Sql = Sql || ' returning_values ((:r1), (:r2))';


Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 65.
(.

if I set the clause to:

Sql = Sql || ' returning_values (:r1), (:r2)';

I get the error:

Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 69.
,.

and If I set the clause to:

Sql = Sql || ' returning_values :r1, :r2';

I get

Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown.
RETURNING_VALUES.
At procedure 'AUX_BORRAME_DRIVER_PROC' line: 22, col: 5.



create procedure aux_borrame_driver_proc(Par integer)
returns
(
r1 integer,
r2 varchar(50)
)
as
DECLARE VARIABLE Sql VARCHAR(1024);
declare variable Pname varchar(200);
BEGIN
select p.sql
from rshk_procedimientos p
where p.id_procedimiento = 1
into :Pname;

Sql = 'execute procedure ' || Pname || '(';
Sql = Sql || CAST(Par AS VARCHAR(20)) || ', ' || CAST(Par AS
VARCHAR(20)) || ')';
Sql = Sql || ' returning_values (:r1), (:r2)';
-- I tested the line above with parenthesis and without.
-- ie. returning_values ((:r1), (:r2))
-- returning_values (:r1), (:r2)
-- returning_values :r1, :r2


EXECUTE STATEMENT Sql;-- into :r1, :r2;
r1 = r1;
END


The firebird 1.5.5 release notes does not give an example on how to
retrive returning values from non selectable stored procedures. I'm not
sure if firebird accepts returning_values as a valid statement in the
dynamic SQL part.

Thanks

Alejandro


--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...>
wrote:
>
> At 10:38 PM 20/11/2009, you wrote:
>
> >create procedure aux_borrame_driver_proc(Par integer)
> >returns
> >(
> > r1 integer,
> > r2 varchar(50)
> >)
> >as
> >DECLARE VARIABLE Sql VARCHAR(1024);
> >declare variable Pname varchar(200);
>
> Missing declarations:
> declare variable v1 integer;
> declare variable v2 varchar(50);
>
> >BEGIN
> > -- get the procedure name from a table
> > select p.sql
> > from rshk_procedimientos p
> > where p.id_procedimiento = 1
> > into :Pname;
> >
> >
> > Sql = 'execute procedure ' || Pname || '(';
> > Sql = Sql || CAST(Par AS VARCHAR(20)) || ', ' || CAST(Par AS
> >VARCHAR(20)) || ')';
>
> Missing:
> Sql = Sql || 'returning_values ((:v1), (:v2))';
>
>
> > EXECUTE STATEMENT Sql into :r1, :r2;
> >
> >END
>
> ./heLen
>




[Non-text portions of this message have been removed]