
499
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
<html>
<head>
<title>Adding Query Data to an Index</title>
</head>
<body>
<!--- Retrieve data from the table. --->
<cfquery name="getEmps" datasource="cfdocexamples">
SELECT * FROM EMPLOYEE
</cfquery>
<!--- Update the collection with the above query results. --->
<cfindex
query="getEmps"
collection="CodeColl"
action="Update"
type="Custom"
key="Emp_ID"
title="Emp_ID"
body="Emp_ID,FirstName,LastName,Salary">
<h2>Indexing Complete</h2>
<!--- Output the record set. --->
<p>Your collection now includes the following items:</p>
<cfoutput query="getEmps">
<p>#Emp_ID# #FirstName# #LastName# #Salary#</p>
</cfoutput>
</body>
</html>
3
Save the file as collection_db_index.cfm in the myapps directory under the web root directory.
4
Open the file in the web browser to index the collection.
The resulting recordset appears.
Search and display the query results
1
Create a ColdFusion page with the following content: