Skip to main content
Participating Frequently
Jun 3, 2008 5:23 PM UTC
Question

Return two queries with <cfreturn>

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 is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    Inspiring
    Jun 3, 2008 7:01 PM UTC
    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.
    Translate
    Inspiring
    Jun 3, 2008 6:22 PM UTC
    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.
    Translate
    kdennis4Author
    Participating Frequently
    Jun 3, 2008 6:30 PM UTC
    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!
    Translate
    Inspiring
    Jun 3, 2008 5:33 PM UTC

    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>

    Translate
    kdennis4Author
    Participating Frequently
    Jun 3, 2008 6:15 PM UTC
    Thank you for your quick response! Just need to figure out how to display it out in my Flex App now.

    Translate