Subject | Re: [firebird-support] Re: Using Cursor in FB1.5 Store Procedure |
---|---|
Author | Helen Borrie |
Post date | 2004-04-30T02:09:30Z |
At 01:41 AM 30/04/2004 +0000, you wrote:
CREATE PROCEDURE (INPUT VARIABLES)
RETURNS (OUTPUT VARIABLES)
AS
DECLARE VARIABLE ...;
ETC.
BEGIN
....
FOR SELECT (OUTER SET) FROM (OUTER TABLE)
...
INTO :VAR1, :VAR2, ....
DO BEGIN
FOR SELECT (INNER SET) FROM (INNER TABLE)
WHERE <SOMETHING> = :AVARIABLE
INTO :VARX, :VARY, ...
DO BEGIN
<BLOCK OF CODE>
END
SUSPEND;
END
END
/hb
>I need to use the cursor to do an inventory calculation which I needYes: nest one FOR SELECT loop inside another:
>to calculate the accumulative quantity balance, rates and the amount
>of each inventory code with a set a formulars.
>
>My plan was to use two set of cursors one is to collect all the
>inventory codes and the second set is to get all the transactions
>base on the fetch next inventory code to do the calculation.
>
>Can this be done in FB1.5?
CREATE PROCEDURE (INPUT VARIABLES)
RETURNS (OUTPUT VARIABLES)
AS
DECLARE VARIABLE ...;
ETC.
BEGIN
....
FOR SELECT (OUTER SET) FROM (OUTER TABLE)
...
INTO :VAR1, :VAR2, ....
DO BEGIN
FOR SELECT (INNER SET) FROM (INNER TABLE)
WHERE <SOMETHING> = :AVARIABLE
INTO :VARX, :VARY, ...
DO BEGIN
<BLOCK OF CODE>
END
SUSPEND;
END
END
/hb