CFLib.org – Common Function Library Project

DynamicValueList(query, col [, delim])

Last updated August 14, 2002

Version: 1 | Requires: ColdFusion 5 | Library: DataManipulationLib

 
Rated 1 time(s). Average Rating: 3.0

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:

view plain print about
<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:

view plain print about
<cfscript>
/**
 * 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);
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson