Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement with Array?

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
US
hello all,
I have this code, I want the SQL to be created depending on the array. I'm not even sure its possible. Everything is fine for the first record but then it equals 100 for the second one, I know that there are 2 records that should meet this requirement in the db.

numCircuits = 1

OPEN deviceCircuits ;
IF sqlca.sqlcode <> 0 THEN
goto rollitout
END IF

FOR count = 1 TO numDevices - 1
holder = sg_deviceid[count]
FETCH deviceCircuits
INTO :sg_circuitID[count];
IF SQLCA.sqlcode = 100 or SQLCA.sqlcode = -1 THEN
CLOSE deviceCircuits ;
numCircuits --
IF sqlca.sqlcode = -1 THEN
MessageBox
(&quot;close:deviceCircuits&quot;, &quot;Jonhhny&quot;,Stopsign!,OKCancel!)
goto rollitout
END IF
END IF
numCircuits++
NEXT



Here is the cursor definition:

DECLARE deviceCircuits CURSOR FOR
SELECT &quot;t_devices&quot;.&quot;circuit_id&quot;
FROM &quot;t_devices&quot;
WHERE &quot;t_devices&quot;.&quot;device_id&quot; = :sg_deviceid[count] ;



Any suggestions??

Thanks
 
Why don't you use a local variable to store the current value in array and use it instead in your code.

Also are you sure there are more than 1 record for the first device_id because changing the array pointer inside the loop will not have any effect on the select statement of the cursor declaration - it will take the value of array as applicable at the time of cursor declaration.
RT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top