QuerySetCell

Sets the cell in a specified column to a specified value. If no row number is specified, the cell on the last row will be set. Returns TRUE.

See also QueryAddColumn and QueryAddRow.

Syntax

QuerySetCell(query, column_name, value [, row_number ])
query

Name of the query already executed.

column_name

Name of the column in the query.

value

Value to set in the specified cell.

row_number

Number of the row. Defaults to last row.

Example

<!--- This example shows the use of QueryAddRow and QuerySetCell --->
<HTML>
<HEAD>
<TITLE>
QuerySetCell Example
</TITLE>
</HEAD>

<BODY>
<H3>QuerySetCell Example</H3>

<!--- start by making a query --->
<CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
SELECT  Course_ID, Number, Descript 
FROM  Courses
</CFQUERY>

<P>The Query "GetCourses" has <CFOUTPUT>#GetCourses.RecordCount#
  </CFOUTPUT> rows.

<CFSET CountVar = 0>
<CFLOOP CONDITION="CountVar LT 15">
 <CFSET temp = QueryAddRow(GetCourses)>
 <CFSET CountVar = CountVar + 1>
 <CFSET Temp = QuerySetCell(GetCourses, "Course_ID", CountVar)>
 <CFSET CountVar = CountVar + 1>
 <CFSET Temp = QuerySetCell(GetCourses, "Number", 100*CountVar)>
 <CFSET CountVar = CountVar + 1>
 <CFSET Temp = QuerySetCell(GetCourses, "Descript", 
  "Description of variable #Countvar#")>
</CFLOOP>

<P>After the QueryAddRow action, the query has
  <CFOUTPUT>#GetCourses.RecordCount#</CFOUTPUT> records.
<CFOUTPUT query="GetCourses">
<PRE>#Course_ID#    #Number#    #Descript#</PRE>
</CFOUTPUT>

</BODY>
</HTML>       



1