You use the CF.query function in your server-side ActionScript to retrieve data from a ColdFusion data source. This function lets you perform queries against any ColdFusion data source.

Note: The CF.query function maps closely to the cfquery CFML tag, although it currently supports a subset of the cfquery attributes.

Use the CF.query function to do the following:

  • Identify the data source you want to query.
  • Pass SQL statements to the data source.
  • Pass other optional parameters to the database.
    For reference information about the CF.query function, see CF.query in the CFML Reference.

About CF.query function syntax

You can write the CF.query ActionScript function using either named arguments or positional arguments. The named argument style is more readable, but it requires more code. Although the positional argument style supports a subset of CF.query arguments, it allows a more compact coding style that is more appropriate for simple expressions of the CF.query function.

Using CF.query named argument syntax

The CF.query function accepts the following named arguments:

// CF.query named argument syntax
datasource:"data source name",
sql:"SQL stmts",

Note: The named argument style requires curly brackets
{} to surround the function arguments.

Using CF.query positional argument syntax

Positional arguments support a subset of CF.query arguments, and you can create more efficient code. The following is the syntax for the positional argument style:

// CF.query positional argument syntax
CF.query(datasource, sql);
CF.query(datasource, sql, maxrows);
CF.query(datasource, sql, username, password);
CF.query(datasource, sql, username, password, maxrows);

Note: When using positional arguments, do not use
curly braces {}.

About the CF.query record set

The CF.query function returns a RecordSet object, which is an instance of the RecordSet class of objects. The RecordSet class provides a wide range of functions for handling record set data. 
You use methods in the RecordSet ActionScript class in your client-side ActionScript to change data returned in the CF.query record set. 
Currently, the following methods are available in the RecordSet class:




Appends a record to the end of the specified RecordSet


Inserts a record at the specified index


Requests notification of changes in a RecordSet object's state


Creates a RecordSet object that contains selected records from the original RecordSet object


Returns the names of all the columns of the RecordSet


Retrieves a record from a RecordSet object


Gets the unique ID corresponding to a record


Returns the total number of records in a RecordSet object


Returns the number of records that have been downloaded from the server


Determines whether a RecordSet object can be edited or manipulated


Determines whether a RecordSet object is local or server-associated


Removes all records from the RecordSet object


Removes a specified record


Replaces the entire contents of a record


Changes the delivery mode of a server-associated record set


Replaces one field of a record with a new value


Sorts all records by a specified compare function


Sorts all the records by a selected field

These functions are available for every RecordSet object returned by the CF.query function to the Flash client. You run these functions as follows:


For example, in the result function that you create to handle record set data returned by the CF.query function, you can reference the database column names returned in the record set using the getColumnNames RecordSet function:

function selectData_Result ( result )
//result holds the query data; employeesView is a Flash list box
stringOutput.text = result.getColumnNames();

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy