?
Solved

Referencing a dynamic referenced query in coldfusion

Posted on 2012-04-13
6
Medium Priority
?
195 Views
Last Modified: 2012-04-16
I used the output of a primary query as the catalyst for a query of query.

I get query sets back in memory and now I want to reference them in a cloop to load a chart.

I am stuck.

I am attaching code, and some output from the run.

I place this tag where my sytnax is wrong:

<!--- Here is the problem --->
cfloop-From.docx
0
Comment
Question by:mahpog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 37844582
If this is the name of your query:

          <cfquery name="qry#ListGetAt(session.qpgm,counter)#" ...>

You must use the same name in the cfloop. ie This

      <cfloop query="qry#ListGetAt(session.qpgm,counter)#" ...>

.. instead of:

       <cfloop query="#qry#session.qpgm##counter##">
0
 

Author Comment

by:mahpog
ID: 37844988
Thanks for the response.

I did have that originally, but I get the following error:

Invalid list index 12.  
In function ListGetAt(list, index [, delimiters]), the value of index, 12, is not a valid as the first argument (this list has 11 elements). Valid indexes are in the range 1 through the number of elements in the list.  

(my session.qpgm has 11 pgms numbers. I used valuelist to seperate them with ","s.)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37845135
Invalid list index 12.  

Edit: Ohh... I see the problem. That code is outside the earlier loop:

        ie  <cfloop From = "1" TO = "#ListLen(session.qpgm)#" INDEX = "Counter">

.. so when the code gets to the query loop, the value of #counter# is 12 causing an error:

       <cfloop query="qry#ListGetAt(session.qpgm,counter)#" ...>

If you want to access the query objects created in the 1st step you need another loop

    <cfloop From = "1" TO = "#ListLen(session.qpgm)#" INDEX = "Counter">
             <cfloop query="qry#ListGetAt(session.qpgm,counter)#" ...>
                  ... some code
             </cfloop>
            ...
     </cfloop>
0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 52

Accepted Solution

by:
_agx_ earned 1500 total points
ID: 37849266
Why delete the question? Seems like the missing loop was the reason for the original error and answers the question asked. ie "Referencing a dynamic referenced query in coldfusion"
0
 

Author Closing Comment

by:mahpog
ID: 37849415
Giving points for original question.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37852042
Thanks but it wasn't a request for points - or I would've posted an "objection" not a comment.  Questions with valid answers aren't normally just deleted. Neither should they given be "B" grades, just to close out the thread .. As you ultimately did use the suggested code, it naturally raises the question - what else is still wrong or not working?

Next time, if you're still having problems in other areas of the code,  better to elaborate on them instead of just deleting or closing the question without explanation.  We can't help if don't know something else is wrong.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question