Query Collection Methods

In this section, we discuss each query collection method.

Syntax

First()

Description

The First method returns the first Query object in the Query collection.

Parameters

None.

Returns

A reference to a Query object if successful, NULL otherwise.

Example

&MyQuery = &MyCollection.First();

Syntax

Item(number)

Description

The Item method returns the Query object that exists at the number position in the Query collection.

Item Considerations

FindQueries and FindQueriesDateRange return both public and private queries. It depends on your database whether the private query is returned first or the public query. If you have two queries with the same name, it depends on your database whether the first use of Item returns the private or the public query.

Parameters

Field or Control

Definition

Number

Specify the position number in the collection of the Query object that you want returned.

Returns

A reference to a Query object if successful, NULL otherwise.

Example

For &I = 1 to &QueryColl.Count; 
   &MyQuery = &QueryColl.Item(&I); 
   /* do processing */ 
End-For;

Syntax

ItemByName(Name)

Description

The ItemByName method returns the Query object with the name Name.

Parameters

Field or Control

Definition

Name

Specify the name of an existing Query within the Query collection. If you specify an invalid name, the object is NULL. The length of this parameter is 30 characters.

Returns

A reference to a Query object if successful, NULL otherwise.

Example

&MyQuery = &MyCollection.ItemByName("PHONELIST");

Syntax

Next()

Description

The Next method returns the next Query object in the Query collection. You can use this method only after you have used the First method: otherwise the system doesn’t know where to start.

Parameters

None.

Returns

A reference to a Query object if successful, NULL otherwise.

Example

&MyQuery = &MyCollection.Next();