Solved

Referencing a dynamic referenced query in coldfusion

Posted on 2012-04-13
6
189 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

24 Experts available now in Live!

Get 1:1 Help Now