View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > QuerySetCell PreviousNext

QuerySetCell

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

True, if successful; False, otherwise.

Query functions

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

QueryAddColumn, QueryAddRow, QueryNew

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. Default: last row.

<!--- This example shows the use of QueryAddRow and QuerySetCell --->

<!--- start by making a query --->
<cfquery name = "GetCourses" datasource = "cfsnippets">
   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>

Contents > CFML Reference > ColdFusion Functions > QuerySetCell PreviousNext

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

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


Holger said on Jan 3, 2005 at 1:10 PM :
After creating a query variable using QueryNew(""), and adding rows, then assigning values to the cells with QuerySetCell() from an existing database query, the datatype of the cell is set automatically.

This converts strings to numbers and strings to dates, which has the affect that the values have to be converted back explicitly to the desired output format.

It would really be nice to be able to specify the datatype either in QueryNew(), QueryAddRow(), or QuerySetCell().
r.sesser said on Jan 17, 2005 at 8:05 AM :
I'm running into the same issue. Creating one query and using QueryAddColumn(), then creating another query from that query. It's converting strings to timestamps. Really undesireable behavior. Anyway around this? It's converting a string like 9-3 to {ts '2005-09-03 00:00:00'}.
wtf-dude-cmon said on May 9, 2005 at 12:59 PM :
Why use this function when there is an equivalent syntax which is easier to read?

myQuery["columnName"][rowNum] = value;
sks447 said on Nov 14, 2006 at 1:11 PM :
Use "JavaCast" to avoid unwanted type conversions.

Example - <QuerySetCell(PortsTable, "PortArrival", "#JavaCast('string', ThisDebark)#")>

 

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

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functa58.htm