Solved

Referencing a dynamic referenced query in coldfusion

Posted on 2012-04-13
6
193 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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

738 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