Subject Re: [firebird-support] What is happend ?
Author Martijn Tonies
Hello,

> So, I have this stored procedure, but only one record I see when her
> finish.... Do you know what is happend ?
>
> Perhaps the terminator character ";" semicolon, I read about change him
> (set term ^ ; ..... End ^ set term : ^) but I try to using in
> IBManager console, IBConsole and IBEasy console, but unsucessful.
>
> Tks for help
>
> Gerson
>
> See the Stored Procedure:
> ------------------------------------------------------------------------
> ---------start
> CREATE PROCEDURE SP_TB_DGA_POS_BAS_02
> RETURNS (
> COD_DGA_POS INTEGER,
> COD_DGA INTEGER,
> DESC_TOTAL VARCHAR (30),
> QTDE_REFIL INTEGER,
> POSOLOGIA VARCHAR (1000),
> RETURN_CODE_O INTEGER)
> AS
> declare variable qtde_total1 numeric(12,3);
> declare variable desc_total1 varchar(20);
> declare variable qtde_total2 integer;
> begin
> for
> select cod_dga_pos
> ,cod_dga
> ,t1.qtde_total
> ,t2.descricao
> ,t1.qtde_refil
> ,t1.posologia
> from tb_dga_pos_bas t1
> left join tb_dga_tpo2 t2 on
> t1.cod_dga_tpo2_total=t2.cod_dga_tpo2
> into :cod_dga_pos
> ,:cod_dga
> ,:qtde_total1
> ,:desc_total1
> ,:qtde_refil
> ,:posologia
> do
> begin
> qtde_total2 = qtde_total1;
> DESC_TOTAL = qtde_total2 || ' ' || desc_total1;
> end
> suspend;
> End

SUSPEND is behind the FOR SELECT ... DO BEGIN...END
loop. Therefor, it will only return a record to the client AFTER
the loop has executed.

Put the SUSPEND inside the loop (in this case, a BEGIN..END
block) and you'll be fine.

> ------------------------------------------------------------------------
> end
> So if I change the end of this SP to:
>
> ,:qtde_refil
> ,:posologia
> do suspend;
> End
>
> This work fine !

See above.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com