Subject Re: [firebird-support] Recursive Selectable Stored Procedure
Author Martijn Tonies
Marius,


>The Stored Procedure so far:
>SET TERM ^^ ;
>CREATE PROCEDURE P_CONSTRUCT_DOWNLINE
>(TOPLEVEL VarChar(15)) returns (REPORTINTO VarChar(15), SELLINGCODE
VarChar(15), SELLNAME VarChar(50), SELLSURNAME VarChar(50))
AS
/*
Procedure: P_CONSTRUCT_DOWNLINE

Author : MJ Labuschagne, Turnkey Information Systems cc
Date : 12/06/2006 07:05:15 AM
Purpose : To Reconstruct the Downline given a Selling Code
Params
------
THISLEVEL : <purpose>
*/
declare variable THISLEVEL varchar(15);
begin
for select ReportInto, SellingCode, SellNames, SellSurname
from M_SELLINGENTITY
where REPORTINTO = :TOPLEVEL
into :REPORTINTO, :SELLINGCODE, :SELLNAME, :SELLSURNAME do
begin
SUSPEND;
THISLEVEL = :SELLINGCODE;
>
>

Use "select ... from P_CONSTRUCT_DOWNLINE(:THISLEVEL)" in
order to use SUSPEND properly. If you don't, only 1 line will be returned.


> execute procedure P_CONSTRUCT_DOWNLINE (:THISLEVEL)
>RETURNING_VALUES :REPORTINTO, :SELLINGCODE, :SELLNAME, :SELLSURNAME;
> SUSPEND;
> end
>end
>^^
>SET TERM ; ^^
>
>The Problem:
>
>The output that gets produced is correct, with the exception that
>from level 3 no data is returned. I have stepped trough the
>procedure using Database Workbench and can actually see the values
>which are not being returned, so I think that there is something
>wrong with my suspends?

Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com