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.
QuerySetCell(query, column_name, value [, row_number ])
QueryAddColumn, QueryAddRow, QueryNew; Creating a recordset with the QueryNew() function in About recordsets in the Developing ColdFusion Applications
ColdFusion MX 7: Changed the behavior of the function so that it does type validation.
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. |
<cfscript>
myQuery=QueryNew("ID,Name,Value","integer,varchar,integer");
// Display an empty recordset
WriteOutput("Empty query object:");
WriteDump(myQuery);
// Create a struct for row values
myStruct=StructNew();
myStruct={ID=001,Name="George",Value=100};
// Create an empty struct for values in row 2
myStruct2=StructNew();
myStruct2={};
// Add values for row 1
QueryAddRow(myQuery,myStruct);
WriteOutput("Recordset with row 1 and empty row 2:");
// Add values for row 2
QueryAddRow(myQuery,myStruct2);
// Result with one row with values and second row empty
WriteDump(myQuery);
// Set cell value for row 2
QuerySetCell(myQuery,"ID","002",2);
QuerySetCell(myQuery,"Name","John",2);
// Display complete recordset with row 1 and 2 populated
WriteOutput("Recordset with cell values set in rows 1 and 2:");
WriteDump(myQuery);
</cfscript>
Output
<cfscript>
myQuery=QueryNew("ID,Name,Value","integer,varchar,integer");
myStruct=StructNew();
myStruct={ID=001,Name="George",Value=100};
QueryAddRow(myQuery,myStruct);
myStruct2={};
QueryAddRow(myQuery,myStruct2);
myQuery.setCell("ID","002",2);
myQuery.setCell("Name","Peter",2);
myQuery.setCell("Value","200",2);
WriteDump(myQuery);
</cfscript>
Sign in to your account