Subject | Re: [firebird-support] Recursive Selectable Stored Procedure |
---|---|
Author | Martijn Tonies |
Post date | 2006-06-12T10:19:19Z |
Marius,
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;
order to use SUSPEND properly. If you don't, only 1 line will be returned.
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
>The Stored Procedure so far:VarChar(15), SELLNAME VarChar(50), SELLSURNAME VarChar(50))
>SET TERM ^^ ;
>CREATE PROCEDURE P_CONSTRUCT_DOWNLINE
>(TOPLEVEL VarChar(15)) returns (REPORTINTO VarChar(15), SELLINGCODE
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)Martijn Tonies
>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?
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