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.

queryAddColumn(query, column_name [, datatype], array_name) → returns numeric

queryAddColumn Argument Reference

query query

column_name string

datatype string

Column data type.
  • Integer
  • Bigint
  • Double
  • Decimal
  • Varchar
  • Binary
  • Bit
  • Time
  • Date

array_name array

Examples sample code invoking the queryAddColumn function

<!--- Make a query. ---> 
 <cfset myQuery = queryNew("")> 
  <!--- Create an array. ---> 
 <cfset FastFoodArray = arrayNew(1)> 
 <cfset FastFoodArray[1] = "French Fries"> 
 <cfset FastFoodArray[2] = "Hot Dogs"> 
 <cfset FastFoodArray[3] = "Fried Clams"> 
 <cfset FastFoodArray[4] = "Thick Shakes"> 
 <!--- Use the array to add a column to the query. ---> 
 <cfset nColumnNumber = queryAddColumn(myQuery, "FastFood", "VarChar", FastFoodArray)> 
 <cfdump var="#myQuery#" /> 

Fork me on GitHub