CFQUERY

I l @ ve RuBoard

<CFQUERY>

Used to pass SQL statements to a data source.

Syntax

 <cfquery name="name_of_query"           datasource="name_of_datasource"          cachedwithin="amount_of_time_to cache_query">   SQL Statements </cfquery> 

Attributes

Name: Required. The name of the query. It must begin with a letter, but can consist of letters , numbers , and underscores. The name attribute is also used to reference the returned recordset.

Datasource: Required (except for dynamic queries [queries where no datasource is set] and queries of queries). This is the name of the ODBC datasource you want to access.

Cachedwithin: Optional. Specifies how long to use a returned recordset before returning to the database for a fresh recordset. To cache a query you must use the same SQL statement for the query every time.

There are other attributes that you can use with <cfquery> that control settings such as database type, how many rows are returned, and how long to run before timing out.

Example

 <!--- retrieve product information --->  <cfquery name="productinfo" datasource="products"          cachedwithin="#createtimespan(0,0,20,0)#">  SELECT *  FROM tblProducts  ORDER BY ProductName </cfquery> 
I l @ ve RuBoard


Macromedia ColdFusion 5. Training from the Source
Macromedia ColdFusion 5 Training from the Source (With CD-ROM)
ISBN: 0201758474
EAN: 2147483647
Year: 2002
Pages: 99
Authors: Kevin Schmidt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net