|
|
|||||||||||||||||||
CFM Tutorial
Part I - Introduction
Part II - Getting Up
Part III - Getting started
Part IV - References |
Cold Fusion Tag: <CFQUERY></CFQUERY> Description
Syntax <CFQUERY NAME="Parameter Name" DATASOURCE="ODBC Data Source" USERNAME="User Name" PASSWORD="Password"> SQL Statement </CFQUERY>
The following example is a simple retrieval query. <CFQUERY DATASOURCE="a2Z" NAME="employees" > SELECT FirstName, LastName, PhoneExtension FROM Employees ORDER BY LastName, FirstName </CFQUERY>The next example demonstrates how dynamic SQL statements can be constructed using the Cold Fusion conditional tags. <CFQUERY DATASOURCE="a2Z" NAME="employees" > SELECT FirstName, LastName, PhoneExtension FROM Employees WHERE employeeID = EmployeeID <CFIF #FirstName# is NOT ""> AND FirstName LIKE '#FirstName#%'" </CFIF> <CFIF #LastName# is NOT ""> AND LastName LIKE '#PhoneExtension#' </CFIF> ORDER BY LastName, FirstName; </CFQUERY> <CFQUERY> can be used to execute any SQL statements, and the following
example demonstrates how <CFQUERY> can be used to delete rows from a
table.
<CFQUERY DATASOURCE="A2Z" > DELETE FROM Employees WHERE EmployeeID = "#EmployeeID#" </CFQUERY> |
References(1) the Cold Fusion Web Application Construction Kit, Second Edition.
|
|||||||||||||||||
|
|||||||||||||||||||