Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 435

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Note: Because you can generate a recordset in ways other than using the
sometimes used instead of Query of Queries.
Benefits of Query of Queries
Performing a Query of Queries has many benefits, including the following:
When you have to access the same tables multiple times, you greatly reduce access time, because the data is already
1
in memory (in the recordset).
A Query of Queries is ideal for tables of 5,000 to 50,000 rows, and is limited only by the memory of the ColdFusion
host computer.
You can perform joins and union operations on results from different data sources.
2
For example, you can perform a union operation on queries from different databases to eliminate duplicates for a
mailing list.
You can efficiently manipulate cached query results in different ways. You can query a database once, and then use
3
the results to generate several different summary tables.
For example, to summarize the total salary by department, by skill, and by job, you can make one query to the
database and use its results in three separate queries to generate the summaries.
You can obtain drill-down, master-detail information for which you do not access the database for the details.
4
For example, you can select information about departments and employees in a query, and cache the results. You
can then display the names of the employees. When users select an employee, the application displays the details of
the employees by selecting information from the cached query, without accessing the database.
You can use a Query of Queries in report definitions to generate subreport data. For more information, see
5
subreports" on page 1033.
Performing a Query of Queries
Perform a Query of Queries as follows:
1
Generate a recordset through a master query.
You can write a master query using a tag or function that creates a recordset. For more information, see
a
recordset" on page 428.
2
Write a detail query—a
cfquery
In the detail query, write a SQL statement that retrieves the relevant records. Specify the names of one or more
3
existing queries as the table names in your SQL code. Do not specify a
If the database content does not change rapidly, use the
4
query results between page requests. This way, ColdFusion accesses the database on the first page request, and does
not query the database again until the specified time expires. Use the
attribute value (in days, hours, minutes, seconds format).
cachedwithin
The detail query generates a new query result set, identified by the value of the
following example illustrates the use of a master query and a single detail query that extracts information from the
master.
Use the results of a query in a query
1
Create a ColdFusion page with the following content:
tag that specifies
dbtype="query"
cachedwithin
Last updated 1/20/2012
tag, the term In Memory Query is
cfquery
.
attribute.
datasource
attribute of the master query to cache the
function to specify the
CreateTimeSpan
attribute of the detail query. The
name
430
"Using
"Creating

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents