CFLib.org – Common Function Library Project

queryColumns(dbquery)

Last updated March 17, 2006

author

John Bartlett

Version: 1 | Requires: CF6 | Library: DataManipulationLib

Description:
Returns the columns in a query in the same order and case returned by the database. Note that you can get the same information in CFMX7 using the result attribute for cfquery.

Return Values:
Returns a list.

Example:

<cfquery name="foo" datasource="cflib">
select id, Description, name
from tbludfs
</cfquery>

<cfoutput>
#querycolumns(foo)#
</cfoutput>

Parameters:

Name Description Required
dbquery Query to examine. Yes

Full UDF Source:

/**
 * Returns query column list.
 * 
 * @param dbquery 	 Query to examine. (Required)
 * @return Returns a list. 
 * @author John Bartlett (jbartlett@strangejourney.net) 
 * @version 1, March 17, 2006 
 */
function queryColumns(dbquery) {
	var queryFields = "";
	var metadata = dbquery.getMetadata();
	var i = 0;
	var col = "";
	
	for (i = 1; i lte metadata.getColumnCount(); i = i+1) {
		col = metadata.getColumnLabel(javaCast("int", i));
		queryFields = listAppend(queryFields,col);
	}

	return queryFields;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson