Skip to main content
Participant
January 8, 2009
Answered

Array of Queries

  • January 8, 2009
  • 5 replies
  • 557 views
I want to define an array where each element could contain the results of a <cfquery>. Is this even possible?

Thanks,
Paul
    This topic has been closed for replies.
    Correct answer Newsgroup_User
    ptrott wrote:
    >
    > I get the following error:
    > "Attribute validation error for tag cfoutput.
    > The value of the attribute query, which is currently myQuery[1], is invalid."
    >

    Yes that is a known limitation of <cfoutput...> that I do look forward
    to the day it is fixed. The 'query' parameter of the <cfoutput> tag
    expects a string that is the name of a variable variable not the actual
    query itself and it can't handle queries in complex variable.

    The workaround is pretty simple if a bit bothersome. Copy the query
    into a simple local variable.

    <cfset localQry = aAry[1]>

    <cfoutput query="localQry">
    ...

    5 replies

    Participating Frequently
    January 8, 2009
    Nevermind...Ian had a better answer. :-)
    ptrottAuthor
    Participant
    January 9, 2009
    Wow. That's kinda silly... Well anyway, thanks guys! You saved my life!
    Newsgroup_UserCorrect answer
    Inspiring
    January 8, 2009
    ptrott wrote:
    >
    > I get the following error:
    > "Attribute validation error for tag cfoutput.
    > The value of the attribute query, which is currently myQuery[1], is invalid."
    >

    Yes that is a known limitation of <cfoutput...> that I do look forward
    to the day it is fixed. The 'query' parameter of the <cfoutput> tag
    expects a string that is the name of a variable variable not the actual
    query itself and it can't handle queries in complex variable.

    The workaround is pretty simple if a bit bothersome. Copy the query
    into a simple local variable.

    <cfset localQry = aAry[1]>

    <cfoutput query="localQry">
    ...
    ptrottAuthor
    Participant
    January 8, 2009
    Ok, I've figured out how to store the result set. I know that I'm successfully storing it in an element in my array because when I use CFDUMP on that element, I can see the result set.

    Now, how do I use that element of my array with <cfoutput>?

    Normally if I was just doing one query I would just say:
    <cfoutput query="myQuery">
    ...
    </cfoutput>

    But when I try to do this:
    <cfoutput query="myQuery[1]">
    ...
    </cfoutput>

    I get the following error:
    "Attribute validation error for tag cfoutput.
    The value of the attribute query, which is currently myQuery[1], is invalid."
    Inspiring
    January 8, 2009
    ptrott wrote:
    > I want to define an array where each element could contain the results of a <cfquery>. Is this even possible?
    >

    Why yes it is possible.

    Just like an array of structures.
    OR
    An array of arrays
    OR
    A structure of queries.
    OR
    A structure of arrays
    OR
    An array of structures of queries.
    OR
    ...

    I think you maybe getting the idea.
    Participating Frequently
    January 8, 2009
    Yes