This function iterates over each row of a query and calls the closure function to work on row of the query. The returned value will be set at the same index in a new query or the provided result query.
Object QueryMap(Object query, UDFMethod mapFunc [, Object resQuery])
Parameter | Description |
query | The query to be iterated over. |
mapFunc | Map function to be called with each row of the query. |
resQuery | Result query whose schema is to be used to populate the results from map function. |
<cfscript> qoptions = {result="myresult", datasource="cfbookclub", fetchclientinfo="yes"}; sampleQuery = QueryExecute("select * from books order by bookid", [] ,qoptions); function mapQuery(any Obj){ if(Obj.ISSPOTLIGHT == "Y") Obj.TITLE = "NEW: " & Obj.TITLE; return Obj; } newQuery = QueryMap(sampleQuery, mapQuery); writedump(newQuery); </cfscript>