View comments | RSS feed

QuerySetCell

Description

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

Returns

True, if successful; False, otherwise.

Category

Query functions

Function syntax

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

See also

QueryAddColumn, QueryAddRow, QueryNew; Creating a record set with a function in Using Query of Queries in ColdFusion MX Developer's Guide

History

ColdFusion MX 7: Changed the behavior of the function so that it does type validation.

Parameters

Parameter Description

query

Name of an executed query.

column_name

Name of a column in the query.

value

Value to set in the cell.

row_number

Row number. The default value is last row.

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>
<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, "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# #Course_Number# #Descript#</pre> </cfoutput>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


jrunrandy said on Jul 20, 2005 at 1:46 PM :
As far as I know, CFML doesn't support the SQL NULL (i.e. three-value-logic). Database fields that are NULL are returned in CFML as empty strings.

Note that <cfqueryparam> and <cfprocparam> do have provisions to set a SQL NULL when updating a database.

FWIW, QuerySetCell(query, column, "", CurrentRow) seems to work for me on a SQLServer timestamp on CF7.
ASandstrom said on Sep 7, 2005 at 10:57 AM :
Starting with ColdFusion MX 7, you cannot add a string literal (for example, "All") to a column that is of type numeric. This was allowed in previous versions of ColdFusion MX. Starting with ColdFusion MX 7, the QuerySetCell function performs type validation.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000601.htm