queryColumnTypes(dbquery)
Last updated April 11, 2006
Version: 1 | Requires: CF6 | Library: DataManipulationLib
Description:
Used in conjuction with QueryColumns(), will return a list of data types such as the following: INTEGER,VARCHAR,CHAR,TIMESTAMP. This can be done in CFMX using getMetaData on the query.
Return Values:
Returns a list.
Example:
<cfquery name="foo" datasource="galaga">
select *
from users
</cfquery>
<cfdump var="#queryColumnTypes(foo)#">
Parameters:
Name | Description | Required |
---|---|---|
dbquery | Query to analyze. | Yes |
Full UDF Source:
/**
* Returns a list of query column data types.
*
* @param dbquery Query to analyze. (Required)
* @return Returns a list.
* @author John Bartlett (jbartlett@strangejourney.net)
* @version 1, April 11, 2006
*/
function queryColumnTypes(dbquery) {
var columnTypes="";
var metadata=dbquery.getMetadata();
var i=0;
var column="";
for (i=1; i lte metadata.getColumnCount(); i=i+1) {
column = metadata.getColumnLabel(javaCast("int",i));
columnTypes = listAppend(columnTypes,dbquery.getColumnTypeName(metadata.getColumnType(dbquery.findColumn(column))));
}
return columnTypes;
}
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