How to add a column to a query with its value in ColdFusion

QueryAddColumn() - add a column to a query with its value

QueryAddColumn.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>QueryAddColumn function example: how to add a column to a query with its value</title>
</head>

<body>
<h2 style="color:HotPink">QueryAddColumn Function Example</h2>

<cfset qColor=QueryNew("ColorID, Name","Integer, VarChar")>

<cfset Temp=QueryAddRow(qColor,2)>

<cfset Temp=QuerySetCell(qColor,"ColorID",1,1)>
<cfset Temp=QuerySetCell(qColor,"Name","AliceBlue",1)>

<cfset Temp=QuerySetCell(qColor,"ColorID",2,2)>
<cfset Temp=QuerySetCell(qColor,"Name","AntiqueWhite",2)>
<cfdump var="#qColor#" label="qColor">


<cfset ColorValueArray=ArrayNew(1)>
<cfset ColorValueArray[1]="##F0F8FF">
<cfset ColorValueArray[2]="##FAEBD7">

<cfset Temp=QueryAddColumn(qColor,"Value","VarChar",ColorValueArray)>
<br /><br />
<cfdump var="#qColor#" label="qColor[after add column]">

</body>
</html>





More ColdFusion examples