querySetCell
Description
Sets a cell to a value. If no row number is specified, the cell on the last row is set.
Categories
Related
History
ColdFusion
MX 7: Changed the behavior of the function so that it does type validation.
Syntax
QuerySetCell(query, column_name, value [, row_number ])
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| column_name | Name of a column in the query. | ||
| query | Name of an executed query. | ||
| row_number | Row number. The default value is last row. | ||
| value | Value to set in the cell. |
Returns
True,
if successful; False, otherwise.
Example
<!--- This example shows the use of QueryAddRow and QuerySetCell --->
<!--- start by making a query --->
<cfquery name = "GetCourses" datasource = "cfdocexamples">
SELECT Course_ID, Descript
FROM Courses
</cfquery>
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, "Number", 100*CountVar)>
<cfset CountVar = CountVar + 1>
<cfset Temp = QuerySetCell(GetCourses, "Descript",
"Description of variable #Countvar#")>
</cfloop>
After the QueryAddRow action, the query has
<CFOUTPUT>#GetCourses.RecordCount#</CFOUTPUT>
records.
<CFOUTPUT query="GetCourses">
<PRE>#Course_ID# #Course_Number# #Descript#</pre> </cfoutput>