CFLib.org – Common Function Library Project

DynamicValueList(query, col[, delim])

Last updated August 14, 2002

author

Raymond Camden

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Description:
The CFML function, ValueList, does not allow you to grab a column dynamically unless you use the evaluate function. This UDF allows you to grab a list of values from one particular column.

Return Values:
Returns a list.

Example:

<cfset test = queryNew("name,age")>
<cfloop index="x" from=1 to=5>
    <cfset queryAddRow(test)>
    <cfset querySetCell(test,"name","Random Name #randRange(1,10000)#")>
    <cfset querySetCell(test,"age","#randRange(1,100)#")>
</cfloop>
<cfdump var="#test#">
<cfdump var="#DynamicValueList(test,"name")#">

Parameters:

Name Description Required
query The query to examine. Yes
col The column to return values for. Yes
delim Delimiter. Defaults to comma. No

Full UDF Source:

/**
 * Returns a value list from a dynamic column of a query.
 * 
 * @param query      The query to examine. (Required)
 * @param col      The column to return values for. (Required)
 * @param delim      Delimiter. Defaults to comma. (Optional)
 * @return Returns a list. 
 * @author Raymond Camden (ray@camdenfamily.com) 
 * @version 1, August 14, 2002 
 */
function DynamicValueList(query,col) {
    var delim = ",";
    if(arrayLen(arguments) gte 3) delim = arguments[3];
    return arrayToList(query[col],delim);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson