• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

QueryAddColumn

Synopsis

                   QueryAddColumn(query, columnname, arrayname)
               

Adds a new column called columnname to query and populates its rows with data from a one-dimensional array specified by arrayname. If an invalid column name (one that violates variable naming rules) is passed, ColdFusion throws an error. The following example adds a new column to a query and populates it with data from an array:

<cfset Products = QueryNew("ProductName, Color, Price, Qty")>
<cfset NewRows = QueryAddRow(Products, 3)>
   
<cfset QuerySetCell(Products, "ProductName", "Widget", 1)>
<cfset QuerySetCell(Products, "Color", "Silver", 1)>
<cfset QuerySetCell(Products, "Price", "19.99", 1)>
<cfset QuerySetCell(Products, "Qty", "46", 1)>
   
<cfset QuerySetCell(Products, "ProductName", "Thingy", 2)>
<cfset QuerySetCell(Products, "Color", "Red", 2)>
<cfset QuerySetCell(Products, "Price", "34.99", 2)>
<cfset QuerySetCell(Products, "Qty", "12", 2)>
   
<cfset QuerySetCell(Products, "ProductName", "Sprocket", 3)>
<cfset QuerySetCell(Products, "Color", "Blue", 3)>
<cfset QuerySetCell(Products, "Price", "1.50", 3)>
<cfset QuerySetCell(Products, "Qty", "460", 3)>
  ....

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint