QueryAddColumn
Adds a column to a query and populates its rows with the contents of a one-dimensional array.
Method Signature
QueryAddColumn(query=[query], columnName=[string], datatype=[any], array=[array])
Arguments
Argument
Type
Required
Description
Default
query
query
true
The query object to which the column should be added.
columnName
string
true
The name of the column to add.
datatype
any
false
The column data type of the new column or the array to populate the column with a generic type of anything.
object
array
array
false
[]
Examples
Tag Example
<!--- Make a query. --->
<bx:set myQuery = queryNew( "" ) >
<!--- Create an array. --->
<bx:set FastFoodArray = arrayNew( 1 ) >
<bx:set FastFoodArray[ 1 ] = "French Fries" >
<bx:set FastFoodArray[ 2 ] = "Hot Dogs" >
<bx:set FastFoodArray[ 3 ] = "Fried Clams" >
<bx:set FastFoodArray[ 4 ] = "Thick Shakes" >
<!--- Use the array to add a column to the query. --->
<bx:set nColumnNumber = queryAddColumn( myQuery, "FastFood", "VarChar", FastFoodArray ) >
<bx:dump var="#myQuery#"/>
member syntax example
add a column to a query using member syntax
books = queryNew( "id,title", "integer,varchar" );
books.addColumn( "author", "varchar", [] );
writeDump( books );
Additional Examples
qry = queryNew( "aaa,bbb" );
QueryAddRow( qry );
QuerySetCell( qry, "aaa", "1.1" );
QuerySetCell( qry, "bbb", "1.2" );
QueryAddRow( qry );
QuerySetCell( qry, "aaa", "2.1" );
QuerySetCell( qry, "bbb", "2.2" );
QueryAddColumn( qry, "ccc", listToArray( "3.1,3.2" ) );
QueryAddColumn( qry, "ddd", "integer", listToArray( "4.1,4.2" ) );
writeDump( qry.COLUMNLIST );
Related
Last updated
Was this helpful?