View comments | RSS feed

QueryAddRow

Description

Adds a specified number of empty rows to a query.

Returns

The number of rows in the query

Category

Query functions

Function syntax

QueryAddRow(query [, number ])

See also

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

Parameters

Parameter Description

query

Name of an executed query.

number

Number of rows to add to the query. The default value is 1.

Example

<h3>QueryAddRow Example</h3>

<!--- 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


Ashish-Saxena said on Sep 3, 2007 at 6:43 AM :
To Run this code without error:
(1) Column name “Number”, should be in select clause.
(2) There is no such column named “Course_Number”, so either remove this or replace this by column name “Number”.
halL said on Sep 4, 2007 at 11:01 AM :
We probably intended to rename the database table column, as Number is not a good name for a DB column.
halL said on Sep 4, 2007 at 11:35 AM :
I suspect we intended to change the column name in the database from Number, which is not a very good name, but never did it.

The example has several other errors.
For a working version see the version in the ColdFusion 8 Livedocs,
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_m-r_17.html

 

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/00000599.htm