Thanks Ben! I was missing the first cfset that you did.
-----Original Message----- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Thursday, January 18, 2007 2:29 PM To: CF-Talk Subject: RE: database function getSubPages returns the query, so you need to treat the result as if it were a query object (just like you would treat the name attribute of a CFQuery tag: <!--- Get query (for shorthand). ---> <cfset qSubPages = getSubPages( 3 ) /> <!--- Tread qSubPages like it is a standard query (which it is). ---> <cfloop query="qSubPages"> .....#qSubPages.COLUMN_NAME_GOES_HERE# </cfloop> ....................... Ben Nadel Certified Advanced ColdFusion MX7 Developer www.bennadel.com Need ColdFusion Help? www.bennadel.com/ask-ben/ -----Original Message----- From: Chad Gray [mailto:[EMAIL PROTECTED] Sent: Thursday, January 18, 2007 2:25 PM To: CF-Talk Subject: database function Hello, I am new to cfc's, functions etc... I have a query that will be used many times and would like to keep the query code in a single file then just call that function when I need it. So say I do this: <CFFUNCTION NAME="getSubPages" RETURNTYPE="query"> <CFARGUMENT NAME="pageID" TYPE="string" REQUIRED="yes"> <cfquery datasource="#application.dsn#" name="SubPages"> SELECT * FROM PageContent WHERE ParentID = #arguments.pageID# </cfquery> <CFRETURN SubPages> </CFFUNCTION> How do I call this function then loop over the returned results? I cant find an example of doing this and everything I have tried has not worked. I should just be able to do this right? #getSubpages("3")# but I get errors about complex data type. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266924 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

