Adobe COLDFUSION 9 Manual page 417

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
• If you use COMPUTE AVG() in your SQL, ColdFusion 9 returns
(ColdFusion 5 and ColdFusion MX 7) returned
• To retrieve results returned by database triggers, add the following connection parameter in the connection string:
AlwaysReportTriggerResults=true
This parameter determines how the driver reports results generated by database triggers (procedures that are stored
in the database and executed, or fired, when a table is modified). For Microsoft SQL Server 2005, this includes
triggers fired by Data Definition Language (DDL) events. If set to true, the driver returns all results, including
results generated by triggers. Multiple trigger results are returned one at a time. Use the method
Statement.getMoreResults to retrieve individual trigger results. Warnings and errors are reported in the results as
they are encountered.
Building queries
As discussed earlier, you build queries by using the
Note: This procedure and many subsequent procedures use the cfdocexamples data source that connects to the
cfdocexamples.mdb database. This data source is installed by default. For information on adding or configuring a data
source, see Configuring and Administering ColdFusion.
Query the table
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<cfquery name="EmpList" datasource="cfdocexamples">
SELECT FirstName, LastName, Salary, Contract
FROM Employee
</cfquery>
</body>
</html>
Note: Adobe recommends that you create structured, reusable code by placing queries in ColdFusion components;
however, for simplicity, the examples here include the query in the body of the ColdFusion page. For more information
about using ColdFusion components, see
Save the page as emplist.cfm in the myapps directory under your web_root directory. For example, the default path
2
on a Windows computer would be:
C:\CFusion\wwwroot\myapps\
Enter the following URL in your web browser:
3
http://localhost/myapps/emplist.cfm
Only the header appears.
View the source in the browser.
4
ColdFusion creates the EmpList data set, but only HTML and text return to the browser. When you view the page's
source, you see only HTML tags and the heading "Employee List." To display the data set on the page, use code tags
and variables to output the data.
avg()
as the column name.)
ave()
tag and SQL.
cfquery
"Building and Using ColdFusion
Last updated 8/5/2010
as the column name. (Previous versions
Components" on page 177.
412

Advertisement

Table of Contents
loading

Table of Contents