You can try setFieldExpression() but its use is fairly limited.

e.g.
<cfset q.setFieldExpression("Color", "Hex", "CONCAT('##', Hex)",
"CF_SQL_VARCHAR")>

It can only be used to _replace_ an existing column in the query, you can't
add a new calculated column to the query.

Cheers, Chris



2008/6/2 Doug Boude <[EMAIL PROTECTED]>:

> i'm sure this is a simple deal, but I need to return a calculated field
> from a custom gateway method. In the end, I want a query that concatenates
> two fields, like "SELECT lastname + "," + firstname from table"
>
> Here's what I have now, which works fine:
>
>         <cfset var Query = createQuery() />
>         <cfset var Where = Query.getWhere() />
>         <cfset var x = 0 />
>         <cfif structKeyExists(arguments, 'FirstName')>
>             <cfset Where.isLike(_getAlias(), "FirstName",
> arguments.FirstName, "Left") />
>         </cfif>
>         <cfif structKeyExists(arguments, 'LastName')>
>             <cfset Where.isLike(_getAlias(), "LastName",
> arguments.LastName,"Left") />
>         </cfif>
>         <cfset Query.returnObjectFields("Client", "FirstName,LastName") />
>         <cfset Query.setDistinct(true) />
>         <cfset Query.setMaxrows(10) />
>         <cfloop list="#arguments.sortBy#" index="x">
>             <cfset Query.getOrder().setAsc("Client", trim(x)) />
>         </cfloop>
>         <cfreturn getByQuery(Query,true) />
>
> SO...what method that I'm not familiar with do I need to add in there to
> get a calculated field like the one I described?
>
> THANKS!!!
>
> Doug  :0)
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --
> Reactor for ColdFusion Mailing List
> [EMAIL PROTECTED]
> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to