> <cfscript>
>       function fncQryGetAllUsers(recordset,orderby,sort) {

>               <cfquery name="#recordset#" datasource="DATABASE">
>                       SELECT *
>                       FROM USERS
>                       ORDER BY #orderby# #sort#
>               </cfquery>

>       }
> </cfscript>

This is producing an error, right? ... In CF 5 you can't use cf tags inside a cfscript 
block, so you can't use <cfquery> to call the query ( although I've seen queries run 
within cfscript -- there is some info about it on www.cfcomet.com last I checked ) ... 
but this was also ( I was under the impression ) the reason for the new syntax for 
creating UDF's in CFMX, i.e.

<cffunction name="fncQryGetAllUsers">
        <cfargument name="recordset">
        <cfargument name="orderby">
        <cfargument name="sort">

        <cfquery ...>...</cfquery>
</cffunction>

> This is the code im using, but also how would I set the recordset as a
> return Parameter?

The trick to setting the query as a return parameters is to not use a dynamic name in 
the query and use the name you want for the recordset in the <cfset> tag ( or script 
set statement ) that uses the UDF, so...

<cfset myquery = fncQryGetAllUsers(orderby,sort)>

Then in the UDF you use something like "qryGetAllUsers" as the name of the query and 
after the query you use <cfreturn value="#qryGetAllUsers#"> ( in CFMX of course ) ...

I don't really get to work with CFMX yet, so my syntax may be off...

> So that I could do something like this.
>
> <cfloop query="#fncQryGetAllUsers('recordsetname','last_name','desc')#">
>
> </cfloop>

This isn't really likely to work ... the UDF will only return one value, and although 
it can be a complex structure, the query attribute of the <cfloop> tag expects a 
simple value ( the name of the query ) ... So in all likelyhood, you'd have to use

<cfset myquery = fncQryGetAllUsers('last_name','desc')>
<cfloop query="#myquery#"></cfloop>

Isaac Dealey
www.turnkey.to
954-776-0046
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to