GoTo to a Label outside a While Loop is NoNo... Use Break and test for
variable conditon after EndWh....
Mike
----- Original Message -----
From: "Frank Radice" <[EMAIL PROTECTED]>
To: "RBASE mailing list (E-mail)" <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 6:07 PM
Subject: While loop problem
> I have a client that has the following code:
>
> DECLARE C1 CURSOR FOR SEL DISTINCT Cust FROM AuditCharge
> OPEN C1 RESET
> SET V vTest INT=NULL
> WHILE vTest IS NULL THEN
> FETCH C1 INTO vCust IND v1
> IF SQLCODE = 100 THEN
> SET V vTest = 1
> GOTO ALLDONE
> ENDI
> WRI .vCust AT 22 29
>
> SEL SUM (SubTot+TaxAmt) INTO vUnPd IND v1 FROM ApplyPay WHERE Cust =
> .vCust
> SEL SUM (PaymentAmt-PaymentUsed) INTO vUaPay IND v1 FROM ApplyPay WHERE
> MethType IN (240 242 250) +
> AND Cust = .vCust
> SET V vCurBal = (.vUnPd-.vUaPay)
> UPDATE Cust SET CurBal = .vCurBal WHERE Cust = .vCust
>
> LABEL ALLDONE
> ENDW
> CLOSE C1
> DROP CURSOR C1
>
> Everything runs OK most of the time, but every so often, the program stops
> with the error message "-Error- GOTO cannot jump into SWITCH or WHILE
> blocks. (686).
>
> It always goes thru the while loop correctly for all Cust (Cust gets
updated
> correctly for ALL Cust in the DECLARE) so it appears to be the GOTO
ALLDONE
> not being able to find the LABEL ALLDONE. I have suggested that they
> replace the GOTO code with BREAK in the IF...THEN. However, I can't
figure
> out why this code works 98% of the time and fails the other 2% of the
time.
> They have WHILEOPT set OFF.
>
> Any thoughts??
>
>
>