Subject Re: [firebird-support] Re: selecting a field by name (using a var)
Author Tomasz Tyrakowski
Hi,

One small improvement.

Instead of

execute statement :loc_sql into :out_fecha;

I'd recommend

for execute statement :loc_sql into :out_fecha do suspend;

Reason: you can't be sure how many records :loc_sql will return, and if
that's more than one, you'll end up with the 'multiple rows in singleton
select' error.

regards
Tomasz

W dniu 2011-11-07 14:04, Sergio pisze:
> well... after doing my post I've found this..
>
> http://www.firebirdfaq.org/faq322/
>
> and I did this
>
> CREATE PROCEDURE PANIO_TERMINADO (
> in_id fk_id,
> in_etapa codigo)
> returns (
> out_fecha fecha_hora)
> as
> declare variable loc_sql descripcion;
> begin
> loc_sql = 'select ' || in_etapa || ' from pedidos_control where id = ' || cast( :in_id as varchar(10));
> execute statement :loc_sql into :out_fecha;
> suspend;
> end
>
> It's OK? or it can be improved? Thanks again!!!!
>
> -sergio
>
>


--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__