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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looping problem

Status
Not open for further replies.

FranckM

Programmer
May 8, 2002
76
0
0
CA
Hi guys, I have a looping problem that I can't find right now.

This is the sql query when I execute this code:

SELECT iogc_instrument.instrument_number, iogc_instrument.iogc_agreement_number FROM ilrs.iogc_instrument WHERE iogc_instrument.instrument_number IN ('2190301020001860','2190301020001863','2000000000005738','2000000000005739')
union SELECT iogc_instrument.instrument_number, iogc_instrument.iogc_agreement_number FROM ilrs.iogc_instrument WHERE iogc_instrument.instrument_number IN ('2190301020001860','2190301020001863','2000000000005738','2000000000005739'.....goes to 254 values)
WHERE iogc_instrument.instrument_number IN ('2190301020001860','2190301020001863','2000000000005738','2000000000005739'.....goes to 254 values)
union SELECT iogc_instrument.instrument_number, iogc_instrument.iogc_agreement_number FROM ilrs.iogc_instrument WHERE iogc_instrument.instrument_number IN ('2190301020001860','2190301020001863','2000000000005738','2000000000005739'.....goes to 254 values)
WHERE iogc_instrument.instrument_number IN ('2190301020001860','2190301020001863','2000000000005738','2000000000005739'.....goes to 254 values)

This is the code I have.

dim arrWords, iLen, icounter, counter, inValues
arrWords = split(strInstruments,",")
arrWords2 = split(strReserves,",")
icounter = 0
counter = 0
invalues = ""

'An other test solution

do while icounter <= ubound(arrwords2)
if counter < 253 and icounter < ubound(arrwords2) then
invalues = invalues & arrwords2(icounter) & &quot;,&quot;
elseif counter = 254 or counter = ubound(arrwords2) then
invalues = invalues & arrwords2(icounter)
end if

if icounter = ubound(arrwords2) then
tempSql = tempSql & strSQL & &quot; AND band_reserve.reserve_number IN ('&quot; & invalues & &quot;')&quot;
elseif counter = 254 then
tempSql = tempSql & strSQL & &quot; AND band_reserve.reserve_number IN ('&quot; & invalues & &quot;') union &quot;
invalues = &quot;&quot;
counter = 0
end if
icounter = icounter + 1
counter = counter + 1
loop

I don't know why it ends as it seems to have an infinit loop, but it does end. I'm baffeled to what is going on. If anyone can help, it would be geatly appreciated. Thanks ;)
 
Do you mean that it should be an infinite loop? I don't see why...the loop runs as many times as there are elements in arrwords2 and then exits. =/
 
The only thing i see is the fact that you are skipping every 253rd value.
Why not put a response.write in the last elseif to print the counter and icounter, and print out the contents of invalues to make sure they aren't duplicating.
Tarwn
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
The values for icounter and counter are fine. I made so that takes all the values including 253. But I still get the same problem...this is really odd...it's like if it was executing

if icounter = ubound(arrwords2) then
tempSql = tempSql & strSQL & &quot; AND band_reserve.reserve_number IN ('&quot; & invalues & &quot;')&quot;


every time it goes through the loop...
 
The problems are fixed, when nothing seems wrong, stupid problems are often the cause eheh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top