| Contents > Developing ColdFusion MX Applications > Using Query of Queries > About record sets > Creating a record set with a function |
|
|
|
|
||
In addition to creating a record set by using a cfquery or other CFML tags, you can create it with the QueryNew() function.
<html>
<head>
<title>The queryNew function</title>
</head>
<body>
<h2>QueryNew Example</h2>
<!--- create a query ---><cfset qInstruments = queryNew("name, instrument,
years_playing")>
<!--- add rows --->
<cfset newrow = queryaddrow(qInstruments, 3)>
<!--- set values in cells --->
<cfset temp = querysetcell(qInstruments, "name", "Thor", 1)>
<cfset temp = querysetcell(qInstruments, "instrument", "hammer", 1)>
<cfset temp = querysetcell(qInstruments, "years_playing", "1000", 1)>
<cfset temp = querysetcell(qInstruments, "name", "Bjorn", 2)>
<cfset temp = querysetcell(qInstruments, "instrument", "sitar", 2)>
<cfset temp = querysetcell(qInstruments, "years_playing", "24", 2)>
<cfset temp = querysetcell(qInstruments, "name", "Raoul", 3)>
<cfset temp = querysetcell(qInstruments, "instrument", "flute", 3)>
<cfset temp = querysetcell(qInstruments, "years_playing", "12", 3)>
<!--- output the query --->
<cfoutput query="qInstruments">
<pre>#name# #instrument# #years_playing#</pre>
</cfoutput>
<h3>Individual record retrieval:</h3>
<cfoutput>
<p>#qInstruments.name[2]# has played #qInstruments.instrument[2]# for
#qInstruments.years_playing[2]# years.
</cfoutput>
</body>
</html>
http://127.0.0.1/myapps/queryNew.cfm
The following figure shows how the output appears:

Note: When you create a record set, you can store in it complex objects, such as arrays and structures. However, you cannot use Query Of Queries on a record set that contains complex objects. For more information on Query of Queries, see About Query of Queries.
|
|
||
| Contents > Developing ColdFusion MX Applications > Using Query of Queries > About record sets > Creating a record set with a function |
|
|
ColdFusion 9 | 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.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/using_r5.htm