Macromedia coldfusion 4.5-cfml language reference User Manual
Chapter 2: ColdFusion Functions
483
QueryAddRow
Adds a specified number of empty rows to the specified query. Returns the total
number of rows in the query that you are adding rows to.
number of rows in the query that you are adding rows to.
See also
QueryNew
,
QueryAddColumn
and
QuerySetCell
.
Syntax
QueryAddRow(
query [, number ])
query
Name of the query already executed.
number
Number of rows to add to the query. Default is 1.
Example
<!--- This example shows the use of QueryAddRow and QuerySetCell --->
<HTML>
<HEAD>
<TITLE>
QueryAddRow Example
</TITLE>
</HEAD>
<HTML>
<HEAD>
<TITLE>
QueryAddRow Example
</TITLE>
</HEAD>
<BODY>
<H3>QueryAddRow Example</H3>
<H3>QueryAddRow Example</H3>
<!--- start by making a query --->
<CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
SELECT Course_ID, Number, Descript
FROM Courses
</CFQUERY>
<CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
SELECT Course_ID, Number, Descript
FROM Courses
</CFQUERY>
<P>The Query "GetCourses" has <CFOUTPUT>#GetCourses.RecordCount#
</CFOUTPUT> rows.
</CFOUTPUT> rows.
<CFSET CountVar = 0>
<CFLOOP CONDITION="CountVar LT 15">
<CFSET temp = QueryAddRow(GetCourses)>
<CFSET CountVar = CountVar + 1>
<CFSET Temp = QuerySetCell(GetCourses, "Course_ID", CountVar)>
<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>
...
<CFLOOP CONDITION="CountVar LT 15">
<CFSET temp = QueryAddRow(GetCourses)>
<CFSET CountVar = CountVar + 1>
<CFSET Temp = QuerySetCell(GetCourses, "Course_ID", CountVar)>
<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>
...