Skip to main content
Inspiring
March 21, 2009
Question

Query Problem

  • March 21, 2009
  • 6 replies
  • 1439 views
I'm really missing something here that I know is very simple and I'm going to kick myself when I get an answer but here goes. I have a query that is getting simple numbers from the db and then a series of if statements looking for the numbers and then performing the function I need. My problem is I'm only getting a positive result on the first row of the query. I created a simple test page to demonstrate.
This topic has been closed for replies.

6 replies

tclaremont
Inspiring
March 23, 2009
If your number set is not as simple as x through y, set up a new list of just the numbers you are searching for, and then loop through that list rather than through the index loop I demonstrated above.

It would reduce the number of lines of code in your example from 66 to 5, and make troubleshooting a bit easier, I would think.
tclaremont
Inspiring
March 23, 2009
If you have a predefined list of numbers that you are looking for, say 1 to 30, try this:

<cfset lstValues = ValueList(GetRawMaterials.market_component_id)>
<cfloop index="Foobar" from="1" to="30">
#Foobar# <cfif ListContains(lstValues, "#Foobar#")>Yes<cfelse>No</cfif>
<br>
</CFLOOP>
InkfastAuthor
Inspiring
March 23, 2009
Thanks for the help, the general consensus is certainly ValueList! After all the time I spent in my CF books looking for anything useful under "List" I should have been looking under "V". Go figure.
tclaremont
Inspiring
March 23, 2009
If you are in a query loop, can't you just use [CurrentRow]?
InkfastAuthor
Inspiring
March 23, 2009
I created the test page to include only the component numbers that are in the db so every one should be a yes. The actual page I have this built into is over a thousand lines of code. The second post by Kibbage is probably what I need and I'm trying it now. What gets me is that in ten years of CF, I've never seen this problem before.
Inspiring
March 23, 2009
Where are all those numbers coming from anyhow? Could you not simply incorporate them into your query somehow?
Inspiring
March 22, 2009
I may not be following your goal but this is what I would do:
Inspiring
March 22, 2009
If you are looking for specific values I would do this:
Inspiring
March 22, 2009
Either use a value list and/or a loop. If you don't specify a row number for your query results, you get the first row only, just as you described.
InkfastAuthor
Inspiring
March 22, 2009
Perhaps I could set row numbers based on the query results... I tried a loop and it just ran over itself and still produced a no result. Actually I've tried many things, this cannot be that complicated.