Skip to main content
Participating Frequently
June 3, 2008
Question

Return two queries with <cfreturn>

  • June 3, 2008
  • 3 replies
  • 380 views
Hello All,

I know I've seen it done somewhere, but I can't seem to find the example. I need to return two queries like:

<cfreturn getCurrentProjects and getProjectRequestByStatus/>

Something like that... not getting the right syntax or something. Any clues?

Thanks!
    This topic has been closed for replies.

    3 replies

    Inspiring
    June 3, 2008
    That changes everything. Ian's answer won't solve your problem either. You are going to have to figure out how to put everything into one query. Looking at the query names in your OP, it seems that it should be quite simple, but they could be misleading.
    Inspiring
    June 3, 2008
    While Ian's answer is correct, my approach would be to run two functions and return one query per. It would be simpler to develop and maintain.
    kdennis4Author
    Participating Frequently
    June 3, 2008
    Thanks Dan.... I would do that, but I've got a Flex Datagrid that needs information from both queries... I'm not sure if I can have two dataProviders for a Grid... I should check that out! Thanks again!
    Inspiring
    June 3, 2008

    You can't!!!! You can only return one value with <cfreturn...>

    .
    ..
    ...

    But of course there is nothing preventing that one value to be a
    structure or array contain two query record sets.

    I.E.

    <cfset var myReturn = strunctNew()>
    ...
    <cfset myReturn.getCurrentProjects = getCurrentProjects>
    <!--- getCurrentProjects is scoped as a local variable with VAR,
    correct? --->
    <cfset myReturn.getProjectRequestByStatus = getProjectRequestByStatus>
    <!--- getProjectRequest is scoped as a local variable with Var, correct?--->

    <cfreturn myReturn>

    kdennis4Author
    Participating Frequently
    June 3, 2008
    Thank you for your quick response! Just need to figure out how to display it out in my Flex App now.