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="GetEmp" DATASOURCE="HRApp">
SELECT * 
FROM Departments
</CFQUERY>

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

<CFSET CountRecs=#GetEmp.RecordCount# +1>
<CFSET Temp=QueryAddRow(GetEmp)>
<CFSET Temp=QuerySetCell(GetEmp, "Department_ID", CountRecs)>
<CFSET Temp=QuerySetCell(GetEmp, "Department_Name", "Engineering")>
<CFSET Temp=QuerySetCell(GetEmp, "Location", "Cambridge")>

<CFOUTPUT QUERY="GetEmp">
    #Department_ID#. #Department_Name#, #Location#<BR>
</CFOUTPUT>
</BODY>
</HTML>