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

Description

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

Category

Query functions

See also

QueryAddColumn, QueryAddRow, QueryNew

Parameters

Parameter
Description
query
Name of the query already executed
column_name
Name of the column in the query
value
Value to set in the cell
row_number
Row number. 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, Course_Num, 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, "Course_Num", 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#    #Course_Num#    #Descript#</PRE>
</cfoutput>

</body>
</html>