Subject EXIT in the inner loop
Author Sudheer Palaparambil
Hi,

In the following procedure, the EXIT in the inner cursor is terminating
the entire
process. What I want is to loop thru sale table and when some condition is
met get out
of the inner loop and continue with the next account_id of the outer loop.

Is it possible ?

Thank you.

Sudheer Palaparambil.

CREATE PROCEDURE IR_AGEING_PROCESS(
DCID SMALLINT,
SFNYR CHAR(4))
AS
VARIABLE DECLARATIONS
BEGIN
FOR SELECT AH.account_id, AH.balance
FROM account_heads AH
WHERE ( AO.company_id = :dCID )
INTO :iAcCd, :dBaln AS CURSOR cT1
DO
BEGIN
IF ( dBaln < 0.00 ) THEN BEGIN /* Debtors will have a negative
balance. */
FOR SELECT SL.bill_amount
FROM sale SL
WHERE ( SL.company_id = :dCID ) AND ( SL.account_id = :iAcCd )
ORDER BY SL.entry_date DESC
INTO :dTran AS CURSOR cT2
DO
BEGIN
dABal = 0.00;
IF ( ( dBaln + dTran ) > 0.00 ) THEN
BEGIN
dABal = dBaln * -1;
EXIT;
END
ELSE
BEGIN
dABal = dTran;
dBaln = dBaln + dTran;
END
UPDATE sale SET ageing_balance = :dABal
WHERE CURRENT OF cT2;
END
END
END
END