User Guide

794 Chapter 3: ColdFusion Functions
QueryAddColumn
Description
Adds a column to a query and populates its rows with the contents of a one-dimensional array.
Pads query columns, if necessary, to ensure that all columns have the same number of rows.
Returns
The number of the column that was added.
Category
Query functions
Function syntax
QueryAddColumn(query, column-name[, datatype], array-name)
See also
QueryNew
, QueryAddRow, QuerySetCell; “Managing data types for columns” in Chapter 22,
“Using Query of Queries,” in ColdFusion MX Developer’s Guide
History
ColdFusion MX 7: Added the datatype parameter.
ColdFusion MX: Changed behavior: if a user attempts to add a column whose name is invalid,
ColdFusion throws an error. (In earlier releases, ColdFusion permitted the add operation, but the
user could not reference the column after adding it.)
Parameters
Parameter Description
query Name of a query object.
column-name Name of the new column.
datatype (Optional) Column data type. ColdFusion generates an error if data you add to
the column is not of this type, or if it cannot convert the data to this type. The
following data types are valid:
Integer: 32-bit integer
BigInt: 64-bit integer
Double: 64-bit decimal number
Decimal: Variable length decimal, as specified by java.math.BigDecimal
VarChar: String
Binary: Byte array
Bit: Boolean (1=True, 0=False)
Time: Time
Data: Date (can include time information)
array-name Name of an array whose elements populate the new column.