Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q3019 Can I use the array functions with my ColdFusion recordset(query)?

You are here: irt.org | FAQ | ColdFusion | Q3019 [ previous next ]

Yes. All ColdFusion array functions are available for use with your recordsets. The only hitch is that you have to use array notation to address the column that you want to work on.

For example, with this code you can grab all of the records in a table and perform different sums on the columns. This way, you have the data you need to do all of your work in one query.

<cfquery name="GetSalesData" datasource="#DSN#" dbtype="ODBC" Username="#UserName#" Password="#Password#">
	SELECT SalesPerson, MonthlyLeads, MonthlySales
	FROM TotalSales
	WHERE Product = 'MondoWidget2000'

<CFSet AllLeads = ArraySum(GetSalesData["MonthlyLeads"])>
<CFSet AllSales = ArraySum(GetSalesData["MonthlySales"])>

Submitted by Bill Sterzenbach

©2018 Martin Webb