Skip to main content
December 16, 2008
Question

Query of query

  • December 16, 2008
  • 1 reply
  • 310 views
I have 2 calls to the same DB I want the first function to make the call and the second to take just the distinct brands from the first query. How does one function kick off another? Does anyone have a sample of this?

<cffunction name="Inventory" access="remote" returnType="query" output="false">
<cfargument name="supplierid" required="false">

<CFQUERY NAME="Inventory" DATASOURCE="COREDATA">
SELECT PNUM5W, PDES5W, SDIVDE, ISCF3W, DIVN5W, COMC5W, COMCDE, PGMJ5W, PGMJDE, SUBSTRING(ANAC5W, 2,14) AS ANAC5W
FROM InvYY
WHERE PGMJ5W = '#SupplierID#'
ORDER BY PDES5W, SDIVDE, PNUM5W
</CFQUERY>
<cfreturn Inventory>
</cffunction>

<cffunction name="Brands" access="remote" returnType="query" output="false">
<cfargument name="supplierid" required="false">
<CFQUERY NAME="Brands" DATASOURCE="COREDATA">
SELECT DISTINCT COMC5W AS data, COMCDE AS label
FROM InvYY

WHERE PGMJ5W = '#SupplierID#'

ORDER BY COMCDE
</cfquery>
<cfreturn Brands>
</cffunction>
    This topic has been closed for replies.

    1 reply

    Inspiring
    December 16, 2008
    Add a third function that:

    1. invokes the Inventory function to get a query object.

    2. invokes the Brands function to get a query object.

    3. Returns an array or struct containing both query objects.
    December 16, 2008
    Im not sure how to have one function invoke another? Is there a sample of this somewhere? I have it so that the inventory fills a data grid and I want the brand function to fill a combobox that i use for filtering. The combo box should have just the brands that are in the datagrid. I was thinking you get all the data. invoke the next function, and that should be about it. Just not sure how to do that.

    Thanks

    George