Session Class Methods in the Query API

The following methods are part of the query API. However, they're used with a Session object.

Syntax

AdvancedSearchQueries(GetFavorites, QueryName, QueryNameOp, Descr, DescrOp, FolderName, FolderNameOp, RecordName, RecordNameOp, FieldName, FieldNameOp, TreeName, TreeNameOp, QueryType, OwnerType, CaseSensitive)

Description

Use the AdvancedSearchQueries method to do more complex searches for queries.

Using Search Operators

All of the parameters for this method work in pairs, with the value in the first of the paired parameters further distinguished by the search operator used in the second parameter. For example, the value specified in FieldName is paired with the value specified in FieldNameOp.

All of the search operator parameters use the following values. Note that the format of the value of the first parameter is sometimes affected by the value of the search operator parameter.

Constant

Description

%Query_AdvSrchBegins

Name begins with the values specified.

%Query_AdvSrchContains

Name contains the value specified.

%Query_AdvSrchEquals

Name equals the value specified.

%Query_AdvSrchNotEquals

The name does not equal the value specified.

%Query_AdvSrchLessThan

The name is less than the value specified.

%Query_AdvSrchLessEquals

The name is less than or equal to the value specified.

%Query_AdvSrchGreaterThan

The name is greater than the value specified.

%Query_AdvSrchGreaterEquals

The name is greater than or equal to the value specified.

%Query_AdvSrchBetween

The name is between two values specified by a comma. Do not use quotation marks. For example, ACCT1,ACCT9.

%Query_AdvSrchIn

The name is in the list specified list. The values are separated with commas. Do not use quotation marks. For example, ACCT1, ACCT2, ACCT3

Parameters

Field or Control

Definition

GetFavorites

Specify whether to return only queries marked as favorites. This parameter takes a Boolean value: true if you only want favorite queries returned, false otherwise. If you specify true for this parameter, all other parameters are ignored.

QueryName

Specify the name of the query you want returned, as a string. Use this parameter with the QueryNameOp parameter.

QueryNameOp

Specify the operator to be used with the QueryName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

Descr

Specify the description you want returned, as a string. Use this parameter with the DescrOp parameter.

DescrOp

Specify the operator to be used with the Descr parameter. The valid values for this parameter are found in the Using Search Operators section, above.

FolderName

Specify the name of the folder of the query or queries you want returned, as a string. Use this parameter with the FolderNameOp parameter.

FolderNameOp

Specify the operator to be used with the FolderName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

RecordName

Specify the name of the record used with the query (queries) you want returned, as a string. Use this parameter with the RecordNameOp parameter.

RecordNameOp

Specify the operator to be used with the RecordName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

FieldName

Specify the name of the field associated with the query (queries) you want returned, as a string. Use this parameter with the FieldNameOp parameter.

FieldNameOp

Specify the operator to be used with the FieldName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

TreeName

Specify the name of the tree associated with the query (queries) you want returned, as a string. Use this parameter with the TreeNameOp parameter.

TreeNameOp

Specify the operator to be used with the TreeName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

QueryType

Specify the type of query, as a string. See below.

OwnerType

Specify the type of owner, whether the query is public or private.

CaseSensitive

This parameter has not yet been implemented.

The values for QueryType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_Query

Find queries of the type Query.

5

%Query_DBAgent

Find queries of the type Process.

4

%Query_Role

Find queries of the type Role

7

%Query_Archive

Find queries of the type Archive.

Returns

A reference to a Query collection containing zero or more queries.

Note: If the result set contains more than 300 rows, only the first 300 rows are returned.

Syntax

AdvancedSearchRecords(RecordName, RecordNameOp, Descr, DescrOp, FieldName, FieldNameOp, TreeName, TreeNameOp, CaseSensitive)

Description

Use the AdvancedSearchRecords method to do more complex searches for records.

Security applies to the results of this list, that is, you have access to all the records your user ID (permission list) allows you to access.

Using Search Operators

All of the parameters for this method work in pairs, with the value in the first of the paired parameters further distinguished by the search operator used in the second parameter. For example, the value specified in FieldName is paired with the value specified in FieldNameOp.

All of the search operator paramerters use the following values. Note that the format of the value of the first parameter is sometimes affected by the value of the search operator parameter.

Constant

Description

%Query_AdvSrchBegins

Name begins with the values specified.

%Query_AdvSrchContains

Name contains the value specified.

%Query_AdvSrchEquals

Name equals the value specified.

%Query_AdvSrchNotEquals

The name does not equal the value specified.

%Query_AdvSrchLessThan

The name is less than the value specified.

%Query_AdvSrchLessEquals

The name is less than or equal to the value specified.

%Query_AdvSrchGreaterThan

The name is greater than the value specified.

%Query_AdvSrchGreaterEquals

The name is greater than or equal to the value specified.

%Query_AdvSrchBetween

The name is between two values specified by a comma. Do not use quotation marks. For example, ACCT1,ACCT9.

%Query_AdvSrchIn

The name is in the list specified list. The values are separated with commas. Do not use quotation marks. For example, ACCT1, ACCT2, ACCT3

Parameters

Field or Control

Definition

RecordName

Specify the name of the record you want returned, as a string. Use this parameter with the RecordNameOp parameter.

RecordNameOp

Specify the operator to be used with the RecordName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

Descr

Specify the description you want returned, as a string. Use this parameter with the DescrOp parameter.

DescrOp

Specify the operator to be used with the Descr parameter. The valid values for this parameter are found in the Using Search Operators section, above.

FolderName

Specify the name of the folder of the records you want returned, as a string. Use this parameter with the FolderNameOp parameter.

FolderNameOp

Specify the operator to be used with the FolderName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

FieldName

Specify the name of the field associated with the record you want returned, as a string. Use this parameter with the FieldNameOp parameter.

FieldNameOp

Specify the operator to be used with the FieldName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

TreeName

Specify the name of the tree associated with the record you want returned, as a string. Use this parameter with the TreeNameOp parameter.

TreeNameOp

Specify the operator to be used with the TreeName parameter. The valid values for this parameter are found in the Using Search Operators section, above.

CaseSensitive

Note: This parameter has not been implemented yet.

Specify whether the search is case-sensitive. This parameter takes a Boolean value: True, the search is case-sensitive, False, it isn't.

Returns

A reference to a QueryDBRecord collection containing zero or more records.

Note: If the result set contains more than 300 rows, only the first 300 rows are returned.

Syntax

FindQueryDBRecords()

Description

The FindQueryDBRecords method returns a reference to a QueryDBRecord collection, filled with zero or more records.

Security applies to the results of this list, that is, you have access to all the records your user ID (permission list) allows you to access.

Parameters

None.

Returns

A reference to a QueryDBRecord collection containing zero or more records.

Syntax

FindQueries()

Description

The FindQueries method returns a reference to a Query collection, filled with zero or more queries.

FindQueries Considerations

FindQueries returns 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

None.

Returns

A reference to a Query collection containing zero or more queries.

Example

In the following example, all available queries are returned:

Local ApiObject &MySession; 
Local ApiObject &MyList; 
 
&MySession = %Session
&MyList = &MySession.FindQueries();

Syntax

FindQueriesDateRange(StartDateString, EndDateString)

Description

The FindQueriesDateRange method returns a reference to a Query collection, filled with zero or more queries that match the specified date range.

FindQueriesDateRange Considerations

FindQueriesDateRange returns 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

StartDateString

Specify the year, month, and day of the beginning date that you want to look for. This parameter takes a string value. You can specify the date either as YYYY-MM-DD or YYYY/MM/DD.

EndDateString

Specify the year, month, and day of the end date. This parameter takes a string value. You can specify the date either as YYYY-MM-DD orYYYY/MM/DD.

Returns

A reference to a Query collection containing zero or more queries.

Example

Local ApiObject &MySession, &QueryList; 
 
&MySession = %Session; 
 
&Start = GetField(VOLUN_ACT_WRK.START_DT_STR).Value; 
&End = GetField(VOLUN_ACT_WRK.END_DT_STR).Value; 
 
&QueryList = &MySession.FindQueriesDateRange(&Start, &End);

Syntax

GetQuery()

Description

The GetQuery method returns an empty query object. After you have an empty query object, you can use it to open an existing query (using the Open method) or to create a new query definition (using the Create method).

Parameters

None.

Returns

A reference to an empty query object if successful, NULL otherwise.

Example

&MyQuery = &MySession.GetQuery();

If &MyQuery.Open("PHONELIST") Then

Syntax

GetQuerySecurityProfile()

Description

Use GetQuerySecurityProfile to return the current user's security profile for PeopleSoft Query. You can then use the QuerySecurityProfile properties to determine if the user can modify queries, the maximum number of rows to fetch for this user, and so on.

Parameters

None.

Returns

A reference to a QuerySecurityProfile if successful, NULL otherwise.

Example

&MySecProfile = %Session.GetQuerySecurityProfile(); 
If &MySecProfile.CanModifyQuery Then 
   /* do some processing */ 
End-If;

Syntax

SearchQueryDBRecords(SearchType, Pattern, CaseSensitive)

Description

The SearchQueryDBRecords method returns a reference to a QueryDBRecord collection, filled with zero or more records.

Security applies to the results of this list, that is, you have access to all the records your user ID (permission list) allows you to access.

You can use wildcard characters % and _ when searching. % means find all characters, while _ means find a single character. For example, if you wanted to find all queries that started with the letter M, use "M%" for Pattern. To find either DATE or DATA, use "DAT_" for Pattern.

These characters can be escaped (that is, ignored) using a \. For example, to search for a query that contains the character %, use \% in Pattern.

If Pattern is an empty string, this method retrieves all queries of the specified type (that is, specifying "" for Pattern is the same as specifying "%").

Parameters

Field or Control

Definition

SearchType

Specify the type of search to be used with the given pattern. You can use either a constant or a number value for this parameter. See below.

Pattern

Specify the pattern to be used when searching for records.

CaseSensitive

Specify whether the search is case-sensitive. This parameter takes a Boolean value: True, the search is case-sensitive, False, it isn't.

The values for SearchType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_FindName

Search for records with the name matching the given pattern.

2

%Query_FindDescr

Search for records with the description matching the given pattern.

3

%Query_FindNameDescr

Search for records with either the name or the description matching the given pattern.

Returns

A reference to a QueryDBRecord collection containing zero or more records.

Example

Local ApiObject &MySession, &DBRecList; 
 
&MySession = %Session; 
 
DBRecList = &MySession.SearchQueryDBRecords(%Query_FindName, "A%", False);

Syntax

SearchPrivateQueries(QueryType, UserId, SearchType, Pattern, CaseSensitive)

Description

The SearchPrivateQueries method returns a reference to a Query collection, filled with zero or more Private queries that match the specified SearchType, UserId, Pattern, and CaseSensitive choice

Parameters

Field or Control

Definition

QueryType

Specify the type of query to be searched for. You can specify either a constant or number value for this parameter. See below.

UserId

Specify the user Id to be used to find currently signed-on user’s private queries.

SearchType

Specify the type of search to be used with the given pattern. You can use either a constant or a number value for this parameter. See below.

Pattern

Specify the pattern to be used when searching for queries.

CaseSensitive

Specify whether the search is case-sensitive. This parameter takes a Boolean value: True, the search is case-sensitive, False, it isn't.

The values for QueryType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_Query

Find queries of the type Query.

3

%Query_DBAgent

Find queries of the type Process.

4

%Query_Role

Find queries of the type Role

10

N/A

Find queries of the type Archive.

The values for SearchType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_FindName

Search for queries with the name matching the given pattern.

2

%Query_FindDescr

Search for queries with the description matching the given pattern.

3

%Query_FindNameDescr

Search for queries with either the name or the description matching the given pattern.

Returns

A reference to a Query collection containing zero or more queries.

Example

The following example retrieves all private queries of type Query which start with A and do a case-insensitive search, that is, get all queries starting with A or a.

Local ApiObject &MySession, &DBRecList; 
 
&MySession = %Session; 
 
DBRecList = &MySession.SearchPrivateQueries(%Query_ListQuery, %UserId, %Query_FindName, "A%", False);

Syntax

SearchPublicQueries(QueryType, SearchType, Pattern, CaseSensitive)

Description

The SearchPublicQueries method returns a reference to a Query collection, filled with zero or more Public queries that match the specified SearchType, Pattern, and CaseSensitive choice.

Parameters

Field or Control

Definition

QueryType

Specify the type of query to be searched for. You can specify either a constant or number value for this parameter. See below.

SearchType

Specify the type of search to be used with the given pattern. You can use either a constant or a number value for this parameter. See below.

Pattern

Specify the pattern to be used when searching for queries.

CaseSensitive

Specify whether the search is case-sensitive. This parameter takes a Boolean value: True, the search is case-sensitive, False, it isn't.

The values for QueryType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_ListQuery

Find queries of the type Query.

3

%Query_ListDBAgent

Find queries of the type Process

4

%Query_ListRole

Find queries of the type Role

10

N/A

Find queries of type Archive

The values for SearchType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_FindName

Search for queries with the name matching the given pattern.

2

%Query_FindDescr

Search for queries with the description matching the given pattern.

3

%Query_FindNameDescr

Search for queries with either the name or the description matching the given pattern.

Returns

A reference to a Query collection containing zero or more queries.

Example

The following example retrieves all public queries of type Query that start with A and does a case-insensitive search, that is, get all queries starting with A or a.

Local ApiObject &MySession, &DBRecList; 
 
&MySession = %Session; 
 
DBRecList = &MySession.SearchPublicQueries(%Query_ListQuery, %Query_FindName, "A%", False);