Oops! I said:
- Declare, type and assign a value to the variable that will be fetched in the first cursor I meant: - Declare, type and assign a value to the variable that will be fetched in the second cursor Emmitt Dove Manager, Converting Applications Development Evergreen Packaging, Inc. [email protected] (203) 214-5683 m (203) 643-8022 o (203) 643-8086 f [email protected] From: [email protected] [mailto:[email protected]] On Behalf Of Emmitt Dove Sent: Tuesday, June 09, 2009 8:00 PM To: RBASE-L Mailing List Subject: [RBASE-L] - RE: (Fwd) [RBASE-L] - RE: Nested While with Fetch Geoffrey, All variables used in the cursor must be defined before the cursor declaration. So, for example: SET VAR vcustnum INTEGER = 0 SET VAR vstate TEXT = ' ' DECLARE cx CURSOR FOR + SELECT custnum, custname, custcity, custstate, custzip + FROM customer + WHERE custnum = .vcustnum AND + Custstate = .vstate In this example I gave the variables (bogus) values; that may be helpful. If your second cursor involves a variable that is defined in the FETCH of the first cursor, I would do things in this sequence: - Declare, type and assign a value to the variable that will be fetched in the first cursor - Declare and type any other variables used in either cursor, assigning bogus values if no value already exists - Declare the second cursor - Declare the first cursor - Open the first cursor - Fetch the first cursor - Open the second cursor with RESET - Fetch the second cursor Emmitt Dove Manager, Converting Applications Development Evergreen Packaging, Inc. [email protected] (203) 214-5683 m (203) 643-8022 o (203) 643-8086 f [email protected] From: [email protected] [mailto:[email protected]] On Behalf Of Geoffrey Wheeler Sent: Tuesday, June 09, 2009 7:14 PM To: RBASE-L Mailing List Subject: [RBASE-L] - (Fwd) [RBASE-L] - RE: Nested While with Fetch Thanks Emmit, With the variable in question I've tried declaring it with a REAL type without setting it to a value (this should give it a null value), initializing it to 0, and not decalaring it (it gives an error - variable not found). The first cursor FETCHes values into the variable OK. The 2 other variables are populated by a variable form and receive valid values. Geoffrey Geoffry, Before you declare your cursors, declare and type all variables that will be used within the cursor definitions, setting them to NULL. Emmitt Dove I have an Rbase 3.1 command file that I've updated to 7.6 I'm having difficulty with one cursor used in a nested WHILE. I declare 2 cursors. The first cursor is opened before and fetched before and in the outside while loop. The second cursor is OPEN RESET before and fetched before and in the nested WHILE. The first cursor is FETCHed OK every loop. The second cursor never has any data (SQLCODE=100). I can never FETCH values into my variables. I checked to see what was happening with the cursor. I can look at variables in the Watch Box but not cursors directly. And because I couldn't FETCH with the cursor (SQLCODE=100) I couldn't examine the 3 variables that it should have populated. So, I closed trace after I had stepped through the loop a couple of times. The LIST CURSOR command at the R>prompt then showed something very strange about the second cursor. The second cursor has 3 variables in the SELECT part of the DECLARE statement. The LIST cursor command showed in the cursor definition that one variable remained as a .vVariableName, one had a constant text value and the other was set to -0- (Null). The one set to NULL is the variable FETCHed by the first cursor in the outside loop. I would expect the OPEN cursor2 RESET command would re-evaluate the variables in the DECLARE statement. In this case only one is re-evaluated because the other 2 have been set in concrete by being evaluated in the DECLARE statement. What is going on here? How can I get the variables in my second cursor to be re-evaluated? Thanks, Geoffrey

