Create method: Query class

Syntax

Create(QueryName, Public, Type, Description, LongDescription)

Description

The Create method creates a new query, based on the parameters passed with the method. The specified query must be a new query.

WARNING:

If you specify the name of a query that already exists, the existing query is overwritten by the new query.

The Create method can be used only with a closed query, it cannot be used on an open query.

After you create a new query, you don't have to open it with the Open method. The existing query object points to the new query.

Creating a new query doesn't create the query in the database. You must save the query (with the Save method) to commit it to the database.

Parameters

Parameter Description

QueryName

Name of the query to be created. This parameter takes a string value. This parameter takes 30 characters. A query name can contain only US ASCII alphabetic and numeric characters, as well as underscores.

Public

Specify if the query is public or private. This parameter takes a Boolean value: True if the query is public, False if it's a private query.

Type

Specify the type of query. This parameter takes either a numeric or constant value. See below.

Description

Specify a short description for the query. This parameter takes a string value. This parameter takes 30 characters.

LongDescription

Specify a long description for the query. This parameter takes a string value. The length of this parameter depends on your system database limit for LONG fields.

The values for Type can be as follows:

Numeric Value Constant Value Description

1

%Query_Query

Query

3

%Query_View

View

4

%Query_Role

Role

5

%Query_DBAgent

Process

7

%Query_Archive

Archive

Returns

An integer value: 0 means the query was created successfully.

Example

/* Use the existing session */ 
&MySession = %Session; 
&MyQry = &MySession.GetQuery(); 
/* create a new query : public type-User */ 
&Rslt = &MyQry.Create("MYQUERY", True, %Query_Query, "My Query", ⇒
"My first Query"); 
If &Rslt = 0 Then 
   /* Query created successfully */ 
Else 
   /* do error processing */ 
End-If;