MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 457

Developing coldfusion mx applications
Table of Contents

Advertisement

Reviewing the code
The master query retrieves the entire Employee table from the CompanyInfo data source (the
CompanyInfo database). The detail query selects only the three columns to display for employees
with the specified last name. The following table describes the code and its function:
Code
cfset LastNameSearch="Doe"
<cfquery datasource="CompanyInfo"
name="master"
cachedwithin=#CreateTimeSpan(0,1,0,0)#>
SELECT * from Employee
</cfquery>
<cfquery dbtype="query" name="detail">
SELECT Emp_ID, FirstName, LastName
FROM master
WHERE LastName=<cfqueryparam
value="#LastNameSearch#"
cfsqltype="cf_sql_char"
maxLength="20"></cfquery>
<cfoutput query=detail>
#Emp_ID#: #FirstName# #LastName# <br>
</cfoutput>
<cfoutput>
#master.columnlist#<br>
</cfoutput>
<cfoutput>
#detail.columnlist#<br>
</cfoutput>
Displaying record set data incrementally
If your database is large, you can limit the number of rows displayed at one time. The following
example shows how to use the
more information on query variables, see
To display record set data incrementally:
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>QoQ with incremental row return</title>
</head>
<body>
<h3>QoQ with incremental row return</h3>
<!--- define startrow and maxrows to facilitate 'next N' style browsing --->
<cfparam name = "MaxRows" default = "5">
<cfparam name = "StartRow" default = "1">
Description
Sets the last name to use in the detail query. In a
complete application, this information comes
from user interaction.
Queries the CompanyInfo data source and
selects all data in the Employees table. Caches
the query data between requests to this page,
and does not query the database if the cached
data is less than an hour old.
Uses the master query as the source of the data
in a new query, named detail. This new query
selects only entries that match the last name
specified by the
query also selects only three columns of data:
employee ID, first name, and last name. The
query uses the
passing erroneous or harmful code.
Uses the detail query to display the list of
employee IDs, first names, and last names.
Lists all the columns returned by the master
query.
Lists all the columns returned by the detail
query.
query variable of a Query of Queries to do this. For
currentRow
"Getting information about query results" on page
variable. The
LastNameSearch
tag to prevent
cfqueryparam
About Query of Queries
433.
457

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents