This function iterates over each row of a query and calls the closure function to work on the row of the query. This function reduces the query to a single value that would be returned.
Object QueryReduce(Object query , UDFMethod reduceFunc [, Object initialValue])
Parameter | Description |
query | The query to be iterated over. |
reduceFunc | The reduce function to be called with each row of the query. |
initialValue | The value to be passed to reduce function for the first row. |
<cfscript> qoptions = {result="myresult", datasource="cfbookclub", fetchclientinfo="yes"}; sampleQuery = QueryExecute("select * from books order by bookid", [] ,qoptions); temp = ""; titles = QueryReduce(sampleQuery, function(temp, element){ temp = temp?:""; temp = temp & element.TITLE & " | "; return temp; }); writeOutput(titles); </cfscript>