Solved

Referencing a dynamic referenced query in coldfusion

Posted on 2012-04-13
6
190 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
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.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now