Solved

Referencing a dynamic referenced query in coldfusion

Posted on 2012-04-13
6
191 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 52

Accepted Solution

by:
_agx_ earned 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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