Query Classes

This chapter provides an overview of the query classes and discusses the following topics:

Click to jump to parent topicUnderstanding Query Classes

You create queries using PeopleSoft Query Manager to extract the data you need from the PeopleSoft database. You can use the query classes in PeopleCode to create a new query, or to modify or delete an existing query. You can also use methods in the Query class to execute the query and have the result set returned as either a rowset or have it format and write the result set to a file. You can also use the query classes to create a SQL statement to be used with the SQL object. In fact, the query classes expose all of the attributes and methods needed by the PeopleSoft Query Manager and Query Viewer applications.

Creating or deleting a query object does not create or delete query information. You must call the appropriate method for that query object directly to create or delete database information, that is, the Create or Delete method.

All of the classes, and most of the properties and methods that make up the query classes, have a GUI representation in PeopleSoft Query Manager. This document assumes that the reader has working knowledge of PeopleSoft Query Manager.

There aren’t any external built-in functions for the query classes: objects are instantiated from other objects or from a session object.

See Also

Session Class

Getting Started with PeopleSoft Query

Click to jump to parent topicCollections in the Query Classes

A collection is a set of similar things, like a group of already existing queries or QueryRecords. As with everything else in the query classes, collections have a GUI representation in PeopleSoft Query.

For example, when you want to open a query, the search page returns a list of all the available queries. This is equivalent to using the FindQueries session class method to get a Query collection.

The following collections are part of the query classes:

Click to jump to parent topicLife Cycle of a Query

At runtime, there are certain things you want to do with a query, like creating one from scratch, updating the criteria for an existing query, running a query, and so on. The following is an overview of this process, and assumes the most common method to use the query API. These steps are expanded in other sections.

  1. Invoke the GetQuery method on the PeopleSoft session object to get a query.

  2. Either open the specific query you want using Open, or create a new query using Create.

  3. Read the query statistics, or make changes as appropriate, adding records, field, criteria, and so on.

  4. Save the changes.

  5. (Optional) Use the RunToRowset method to run the query.

    Note. Be careful whenever you write a PeopleCode program that uses the RunToRowset method because this method could return a large amount of data that could potentially exceed the memory available. For this reason, RunToRowset should be used only when you know that the query being executed returns a reasonable amount of data, or be sure to use the MaxRows parameter to control the maximum amount of data that can be returned.

    Alternatively, you can:

  6. Close the query.

  7. If you want, you can navigate to PeopleSoft Query Manager, Query Viewer or the Query Designer to run the query.

Life cycle of a Query object

Click to jump to parent topicQuery Classes Hierarchy

There are many different classes used with the query API. The following flowcharts illustrate all the different classes and how they're interrelated.

Query API class hierarchy (part 1 of 3)

Query API class hierarchy (part 2 of 3)

Query API class hierarchy (part 3 of 3)

Click to jump to parent topicQuery API Overview

The query API is made up of many classes. The following are the primary parts, generally used when updating a query:

Query

The query definition.

QuerySelect

A query SELECT statement. There can be multiple QuerySelect objects for queries that involve unions or subqueries. Each select (or union or subquery) consists of QueryRecords, QueryOutputFields, QuerySelectedFields, and QueryCriteria.

QueryRecords

The records that are part of the existing QuerySelect definition.

QueryOutputFields

The fields that you've selected to be displayed when the results of the query are run.

QuerySelectedFields

All the fields that make up the QuerySelect Definition. These include the fields selected as output fields, and fields added as part of Query Expressions.

QueryCriteria

The criteria for the query.

QueryExpression

The Query expressions that can contain SQL functions or other SQL fragments.

QueryList

The lists used in the in-list functionality for criteria.

QueryPrompt

The prompts used in criteria.

QueryDBRecords and QueryDBRecordFields

All the records available to be used as QueryRecords, and all the fields available. This list is restricted based on a user’s Query Access Security Groups.

Click to jump to top of pageClick to jump to parent topicQuery

A database query. You must get a query before you can access any of the other query classes. You can then create a new query and save it to the database, or open an existing query and modify it.

Click to jump to top of pageClick to jump to parent topicQuerySelect

Each query is composed of one or more select statements:

Main Select

The instance of the first SELECT statement of the Query is the Main Select. There can only be one Main Select statement in the Query. This instance consists of the QueryOutputFIelds, QueryCriteria, and the QueryExpressions for the Main Select statement.

Union

In addition to the Main Select, a query can have one or more unions. The Unions are added by using the AddUnion method.

Sub-Select

A subquery used in the criteria of the Main Select or in a Union.

Click to jump to top of pageClick to jump to parent topicQueryRecords

The records that are part of an existing query definition. In PeopleSoft Query, these are the records listed on the query tab. Each QuerySelect has its own set of QueryRecords.

Click to jump to top of pageClick to jump to parent topicQueryOutputFields

The fields that you've selected to be part of the query definition. They're called output fields because when you run the query, these are the fields that make up the output columns.

In PeopleSoft Query, these are the fields listed on the Fields tab.

The collection of QueryOutputFields does not necessarily include all columns returned in query resultset. This collection only includes columns that have been added to query output collection using the query classes or by an end-user designing a query.

PeopleSoft Query can also add additional columns for related language processing and also for translate labels on fields, and so you cannot use the Query Output Collections as a way to discover all of the columns that are returned in the resultset or by executing the SQL generated from a query.

Click to jump to top of pageClick to jump to parent topicQuerySelectedFields

All the fields that make up the query definition. These include the fields selected as output fields, and fields added as QueryExpressions.

Click to jump to top of pageClick to jump to parent topicQueryCriteria

The selection criteria for the query. Each QueryCriteria object is made up of the following:

Logical

Any criteria objects after the first must include have a Logical value, either AND or OR.

Expression 1

A field or value that you want to base the selection criterion on, that is, Expression1 is the left-hand side of the criterion's comparison.

Operator

A mathematical or other operator used to specify the relationship between Expression 1 and Expression 2.

Expression 2

A field or other value, also called a comparison value, used with Expression 1, that is, Expression2 is the right-hand side of the criterion's comparison.

In PeopleSoft Query, a QueryCriteria is under the Criteria tab.

Expression can be made up of constant values, fields, subqueries, and so on.

See Also

Working With Query Criteria and Expressions

Click to jump to top of pageClick to jump to parent topicQueryDBRecords and QueryDBRecordFields

A QueryDBRecord is a record in the database that can be used as a QueryRecord. The list of records is controlled by security: the only records displayed as QueryDBRecords are records accessible by the user.

The QueryDBRecordFields are the fields that make up the QueryDBRecords.

In PeopleSoft Query, the QueryDBRecords are under the Record tab. After you click on the plus sign next to a record, the QueryDBRecordFields are displayed.

Click to jump to parent topicWorking With Query Criteria and Expressions

If you run a query after selecting the QueryFields (which executes a SQL statement, such as SELECT EMPLID, DEPTID from PS_QE_EMPLOYEE), the system retrieves all the data in those columns; that is, it retrieves the data from every row in the QueryRecord or records because there is no filter limiting the number of rows.

You can select which rowsof data you want by adding selection criteria to the query.

This document assumes that you know how to use selection criteria. This section discusses working with the QueryCriteria and QueryExpression objects in the query API only.

This section discusses how to:

See Also

Defining Selection Criteria

Click to jump to top of pageClick to jump to parent topicSetting the Expression Type

Before you can add a new expression (either Expression 1 or Expression 2) to your QueryCriteria, you must set the type for the expression.

The following code example adds a new criteria, sets the type for the first expression, adds the first expression to the main select of the query definition, then does the same thing for the second expression.

&MyQuerySelect = &MyQuery.QuerySelect; &MyCriteria = &MyQuerySelect.AddCriteria(); /* make expression 1 a field */ &MyCriteria.Expr1Type = %Query_ExprField; /* add the ABSENCE_TYPE field */ &MyCriteria.AddExpr1Field("A", "ABSENCE_TYPE"); /* make it not equal to */ &MyCriteria.Operator = %Query_CondNotEqual; /* Make expression 2 a constant */ &MyCriteria.Expr2Type = %Query_ExprConstant; &MyCriteriaExpr = &MyCriteria.AddExpr2Expression1(); &MyCriteriaExpr.Text = "VAC";

Click to jump to top of pageClick to jump to parent topicAdding New Expressions

When you use any of the QueryCriteria methods to add either a new Expression 1 or Expression 2, you destroy the existing value.

In general, you should use the QueryCriteria methods to add a new Expression 1 or Expression 2 only when you're adding a new criteria to a query.

Click to jump to top of pageClick to jump to parent topicAdding an Operator and Expression 2 Dependencies

Which values are valid for the Expression 2 type (Expr2Type property) depend on the value of the Operator property.

The following table describes which Expr2Type values are valid with which values of Operator.

Operator

Expression 2

equal to

not equal to

greater than

not greater than

less than

not less than

Constant

Field

Expression

Subquery

Prompt

Exists

not exists

Subquery

Like

not like

Constant (with wildcards)

Prompt

is null

is not null

 

in tree

not in tree

Tree Option

Tree Prompt Option

Eff Date <=

Eff Date >=

Eff Date <

EffDate >

Field

Expression

Constant

Current Date

First Eff Date

Last Eff Date

 

in list

not in list

In list

Subquery

Between

Not Between

Const-Const

Const-Field

Const-Expr

Field-Const

Field-Field

Field-Expr

Expr-Const

Expr-Field

Expr-Expr

See Also

Operator

Click to jump to top of pageClick to jump to parent topicSetting a Drilling URL

A drilling URL provides a clickable link in query results allowing a user to drill from the query results to another query, to another component, or to an external site. A drilling URL is defined as a special type of query expression. Like other query expressions, the user can set the drilling URL on the Edit Expression Properties page, or the drilling URL can be set in a PeopleCode program as follows:

/* Setting a drilling URL */ &aQueryExpr = &aQuerySelect.AddExpression(&sExprName); /* Set the expression type to drilling URL */ &aQueryExpr.Type = %FieldType_URL; /* Set the expression text and number from record fields */ /* The Text property must conform to expected formats */ &aQueryExpr.Text = &rRecordExpr.QRYCRIT1EXPRTEXT.Value; &aQueryExpr.ExpNum = &rRecordExpr.QRYCRIT1EXPRNUM.Value;

For a drilling URL, the Text property of the QueryExpression object must conform to one of three expected formats. The value of the Text property is not validated; therefore, it is the calling program’s responsibility to ensure that value is complete and correctly formatted. Each of the drilling URL types has a different format as follows:

See Also

AddTrackingURL

SetTrackingURL

Text

Type

Drilling URL in Oracle PeopleSoft Query

Click to jump to parent topicQuery Monitor

The query classes provide many methods and properties for examining the QueryStatistics, which you can use to report on the average execution time, the last date and time the query was run, and so on.

You can view the statistics for a query before you save it to the database.

See Also

Getting Started with PeopleSoft Query

Click to jump to parent topicUsing Query Metadata

There are two ways of accessing information about a query:

If you use the Metadata property, the information is presented in a different format. It is also read-only. Using this property can be a quick and easy way to access information about a query.

Each Query Metadata object is a name-value pair. Name is an indicator of which Query Metadata property you're accessing, and Value is the value of that property.

While the value of each Query Metadata property is unique, the name may or may not be. For example, there is only one description (Descr) for each query, so there is only one Query Metadata property with name equal to Descr and value equal to the description for the query.

However, there may be more than one record for a query. A Query Metadata property exists for each record, with name equal to Record and value equal to one of the records in the query. The same is true for Input Param, Expression, Field, and Heading.

The following is a simple PeopleCode program to get the Query Metadata for a private query, ADDRESS_TEMP:

Local ApiObject &MyQuery, &MyMetacol, &MyMetadata; Local File &MyFile; &MyFile = GetFile("Metadata.Txt", "A"); &MyQuery = %Session.GetQuery(); &Rlst = &MyQuery.Open("ADDRESS_TEMP", False, 1); If &Rlst = 0 Then &MyMetacol = &MyQuery.metadata; &MyFile.WriteLine("Name Value"); &MyFile.WriteLine("-----------------------"); For &i = 1 To &MyMetacol.count &MyMetadata = &MyMetacol.item(&i); &Name = &MyMetadata.name; &Value = &MyMetadata.Value; &MyFile.WriteLine(&Name | " " | &Value); End-For; Else WinMessage("Open query not successful"); End-If;

Here is the sample output:

Name Value ----------------------- ​Descr Temporary address query for testing LongDescr Public/Private QEDMO LastUpdDttm 2001-11-19-15.06.22.930000 LastUpdOprId QEDMO Record QE_PERS_DATA Field QE_EMPLID Field QE_NAME Field ADDRESS1 Field ADDRESS2 Field ADDRESS3 Field ADDRESS4 Field CITY Field COUNTY Field STATE Field QE_ZIP Field QE_COUNTRY Heading ID Heading Name Heading Address 1 Heading Address 2 Heading Address 3 Heading Address 4 Heading City Heading County Heading St Heading QE_ZIP Heading QE_COUNTRY

Click to jump to parent topicRunning a Query

With query API, you have the following options for running a query:

Note. For the query classes, all date, time, and datetime fields that are part of a query are now required fields when running a query.

Considerations Using the RunTo Methods

RunToRowset may require a lot of memory for the Rowset object; therefore, it also takes more processing time. PeopleSoft recommends that RunToRowset not be used for retrieving large result sets, on the order of 50,000 or more items.

All of the RunTo methods can be called to run a query before saving it—that is, it isn't necessary to first save the query.

The last parameter of all of the RunTo methods is the maximum number of rows to fetch.

See Also

RunToFile

RunToRowset

RunToString

Click to jump to top of pageClick to jump to parent topicSpecifying the User’s Language

For scheduled queries, the system uses the language specified in the user’s profile. It does not use the language selected during signon. The system also uses the International and Regional settings the user specified using My Personalizations. If no personal setting have been specified, the system uses the default installation international settings.

Note. Most PeopleSoft components can default to international settings from the browser if the user has not set any user specific settings. However, this is not available for scheduled queries or any Process Scheduler processes.

Click to jump to parent topicQuery Security

Security is critical for your business data. Typically, you don’t want everyone in your company to have access to all the data. All the standard security features used with PeopleSoft applications are integrated in the PeopleSoft Query, as well as the query classes.

In addition, you can use the QuerySecurityProfile Class to view the current user's security profile for PeopleSoft Query. This class doesn't contain any methods, and all the properties are read-only.

See Also

QuerySecurityProfile Class

PeopleSoft Query Security

Understanding PeopleSoft Security

Click to jump to parent topicError Handling With Query Classes

All errors for the query classes, like the other APIs, are logged in the PSMessages collection, instantiated from a session object. In addition, some methods return error codes. See the individual method description to see if it returns anything.

The query classes log errors "interactively", that is, as they happen. For example, suppose you specified an invalid query name. The error would be logged in the PSMessages collection as soon as you executed the GetQuery method.

When to check for errors is application-specific. However, if you check for errors after every assignment, you may see a performance degradation.

PeopleSoft recommends that you check for invalid prompts after using any of the following methods or properties:

The easiest way to check for errors is to check the number of messages in the PSMessages collection, using the Count property. If the Count is 0, there are no errors.

Local ApiObject &MySession; Local ApiObject &ERRORCOL; Local ApiObject &Query, &QueryList; &MySession = %Session; If &MySession Then /* connection is good */ &QueryList = &MySession.SearchPublicQueries(%Query_ListQuery, ⇒ %Query_FindName, "%", True); For &I = 1 to &QueryList.Count &Query = &QueryList.Item(&I); /* Do processing */ ​/* Do error checking */ &ERRORCOL = &MySession.PSMessages; If (&ERRORCOL.Count <> 0) Then /* errors occurred - do processing */ Else /* no errors */ End-If; ​ End-For; Else /* do processing for no connection */ End-If;

See Also

Error Handling

Click to jump to parent topicUnderstanding QueryOutputFields and QuerySelectedFields

If you select a field from a Query Record, it becomes a QueryOutputField, that is, it becomes one of the columns in the SQL output. QuerySelectedFields consist of displayed fields and Query Expression Fields.

QuerySelectedFields and QueryOutputFields have all the same methods and properties, so in this documentation, they're described together under the heading QueryField.

The collection of QueryOutputFields does not necessarily include all columns returned in query resultset. This collection only includes columns that have been added to query output collection using the query classes or by an end-user designing a query.

PeopleSoft Query can also add additional columns for related language processing and also for translate labels on fields, and so you cannot use the Query Output Collections as a way to discover all of the columns that are returned in the resultset or by executing the SQL generated from a query.

Click to jump to parent topicUnderstanding Having Criteria

You can have where (simple) criteria or having criteria in a query. In most cases, you have a WHERE clause only—that is, simple criteria. Having criteria is only used in some special cases of aggregation queries. They represent the HAVING clause of the SQL statement, similar to the following:

select A.DEPTID, COUNT(A.EMPLID) from PS_QE_EMPLOYEE A group by A.DEPTID having COUNT(A.EMPLID)>5

Having criteria are separated from simple criteria. They're accessed as follows:

See Also

Defining HAVING Criteria

Click to jump to parent topicData Type of Query Objects

All query objects, like a query collection, a QueryDBRecord, a QueryExpression, and so on, are declared as type ApiObject. For example,

Global ApiObject &MyQuery; Local ApiObject &MyExpression;

Click to jump to parent topicScope of Query Objects

All query objects can be instantiated from PeopleCode only.

You can use this object anywhere you have PeopleCode—that is, in an application class, Application Engine PeopleCode, record field PeopleCode, and so on.

You can only instantiate a query object from a Session object. You must instantiate the Session object before you can instantiate a query object or query collection. Use the %Session system variable to connect to the existing session.

Local ApiObject &QueryList; Local ApiObject &MySession; &MySession = %Session; If &MySession <> Null Then /* connection is good */ /* Search for public queries of type QUERY, search both the name and*/ /* description for the pattern MyQ%, and do a case insensitive search */ &QueryList = &MySession.SearchPublicQueries(1, 3, "MyQ%", False); Else /* do error processing */ End-if;

Click to jump to parent topicQuery Classes Reference

This section provides a reference to the following topics:

Click to jump to parent topicSession Class Methods in the Query API

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

See Also

Session Class.

Click to jump to top of pageClick to jump to parent topicAdvancedSearchQueries

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

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.

Click to jump to top of pageClick to jump to parent topicAdvancedSearchRecords

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

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.

Click to jump to top of pageClick to jump to parent topicFindQueryDBRecords

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.

See Also

QueryDBRecord Collection, QueryDBRecord Class.

Click to jump to top of pageClick to jump to parent topicFindQueries

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();

See Also

Open, FindQueriesDateRange, Query Collection.

Click to jump to top of pageClick to jump to parent topicFindQueriesDateRange

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

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);

See Also

FindQueries, Open, Query Collection.

Click to jump to top of pageClick to jump to parent topicGetQuery

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

See Also

Session (query API) class: FindQueries method, FindQueriesDateRange method, Open method, Create method.

Click to jump to top of pageClick to jump to parent topicGetQuerySecurityProfile

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;

See Also

QuerySecurityProfile Class.

Click to jump to top of pageClick to jump to parent topicSearchQueryDBRecords

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

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);

See Also

Session (query API) class: FindQueryDBRecords method.

Click to jump to top of pageClick to jump to parent topicSearchPrivateQueries

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

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);

See Also

Session (query API) class: FindQueries method, FindQueriesDateRange method, SearchPublicQueries method.

Click to jump to top of pageClick to jump to parent topicSearchPublicQueries

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

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);

See Also

Session (query API) class: FindQueries method, FindQueriesDateRange method, SearchPrivateQueries method.

Click to jump to parent topicQuery Collection

A query collection is returned from the following session methods:

See Also

AdvancedSearchQueries

FindQueries

FindQueriesDateRange

SearchPublicQueries

SearchPrivateQueries

Click to jump to parent topicQuery Collection Methods

In this section, we discuss each query collection method.

Click to jump to top of pageClick to jump to parent topicFirst

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();

Click to jump to top of pageClick to jump to parent topicItem

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

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;

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(Name)

Description

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

Parameters

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");

Click to jump to top of pageClick to jump to parent topicNext

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();

Click to jump to parent topicQuery Collection Property

In this section, we discuss the Count query collection property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of Query objects in the Query collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQuery Class

A query object is returned from the following:

See Session (query API) class: GetQuery method.

See Query Collection.

Click to jump to parent topicQuery Class Methods

In this section, we discuss each Query class method in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAddPrompt

Syntax

AddPrompt(PromptName)

Description

The AddPrompt method adds a prompt with the given name to the query definition. This method returns a new QueryPrompt object that you can then use to specify details about the prompt.

Note. Prompt names are not checked for uniqueness. Each new prompt is just added to the list of prompts.

Parameters

PromptName

Specify the name of the new prompt with a string. The length of this parameter is 30 characters.

Returns

A reference to a QueryPrompt object.

See Also

Query class: DeletePrompt method, Prompts property, QueryPrompt Class .

Click to jump to top of pageClick to jump to parent topicAddQuerySelect

Syntax

AddQuerySelect()

Description

Use the AddQuerySelect method to add the first Query Select statement into the query definition. This method returns the instance of the newly created QuerySelect.

Parameters

None.

Returns

A reference to a QuerySelect object. If the query already contains the Main Select, it returns NULL.

See Also

QuerySelect Collection.

Click to jump to top of pageClick to jump to parent topicAddTrackingURL

Syntax

AddTrackingURL(URLString)

Description

Use this method to define the base URL used to construct a fully qualified drilling URL. A base URL consists of the following elements:

http://server_name/servlet_name/site_name/portal_name/node_name

For example:

http://server.mycompany.com:8080/psp/ps_2/EMPLOYEE/EMP_LOCAL

The string passed in as the base URL is not validated; therefore, it is the developer’s responsibility to ensure that the value is complete and correctly formatted.

This method is used when a program does not have context to identify the site, portal, and node. For example, batch programs such as Application Engine programs do not operate in the context of a site, portal, and node. Consequently, prior to invoking an Application Engine program, the calling program needs to define and store the base URL so that the Application Engine program can use this stored value with the AddTrackingURL method.

Parameters

URLString

Specify the base URL as a string. The base URL is used to construct a fully qualified drilling URL.

Returns

None.

Example

The ExecQry step of the PSQUERY Application Engine program invokes the AddTrackingURL method using a value stored in the run control table prior to executing the query.

&aQry = %Session.GetQuery(); If &aQry.Open(PSQUERY_AET.QRYNAME, &bPublic, False) = 0 Then &aQry.AddTrackingURL(PSQUERY_AET.URL); ... &Result = &aQry.RunToFile(&rcdQryPrompts, &sOutFile, %OutDestFormat, 0); End-if;

See Also

SetTrackingURL

Setting a Drilling URL

Drilling URL in Oracle PeopleSoft Query

Click to jump to top of pageClick to jump to parent topicClose

Syntax

Close()

Description

The Close method closes the query, freeing the memory associated with that object, and discarding any changes made to the query since the last save. The Close method can be used only on an open query, not a closed query. This means you must have opened the query with the Open or Create methods before you can close it. To save any changes, you must use the Save method before using Close.

It’s very important to close your query when you’re finished processing. Canceling out of a page does not close a query. You may receive error messages every other time you run your program if you haven’t closed your queries.

Parameters

None.

Returns

None.

See Also

Query class: Open method, Save method, Create method.

Click to jump to top of pageClick to jump to parent topicCopyPrivateQuery

Syntax

CopyPrivateQuery(QueryName, QryType, TargetUserID)

Description

The CopyPrivateQuery method copies the query from the current user to a user specified by the target user ID.

Parameters

QueryName

Name of the query to be copied, as a string.

QryType

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

TargetUserID

The user ID to which the query is to be copied, as a string.

The values for QryType can be as follows:

Numeric Value

Constant Value

Description

1

%Query_Query

Find queries of the type Query.

4

%Query_Role

Find queries of the type Role.

5

%Query_DBAgent

Find queries of the type Process.

7

%Query_Archive

Find queries of the type Archive.

Returns

0 if successful.

Click to jump to top of pageClick to jump to parent topicCreate

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

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 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;

See Also

GetQuery, Close, Save.

Click to jump to top of pageClick to jump to parent topicDelete

Syntax

Delete()

Description

The Delete method deletes the specified query from the database. The Delete method can be used only with an open query, it cannot be used on a closed query. Before you use the Delete method, you must explicitly open the query object to be deleted (with either the Open or Create method.)

Parameters

None.

Returns

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

See Also

Query class: Save method.

Click to jump to top of pageClick to jump to parent topicDeletePrompt

Syntax

DeletePrompt(PromptNumber)

Description

The DeletePrompt method deletes a prompt from a query definition.

Parameters

PromptNumber

Specify the numeric location in the query definition of the prompt that you want to delete.

Returns

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

See Also

Query class: AddPrompt method, Prompts property, QueryPrompt Class .

Click to jump to top of pageClick to jump to parent topicFindExpression

Syntax

FindExpression(ExpressionNumber)

Description

Use the FindExpression method to search the query definition for an expression with the given expression number. Although expressions are associated with the QuerySelect in which they are defined, PeopleSoft Query doesn't qualify expressions by Select number. Therefore, each expression has a unique number across all QuerySelect objects.

Parameters

ExpressionNumber

Specify the numeric value of the expression number to be searched for in the query definition.

Returns

A QueryExpression object if successful, NULL otherwise.

See Also

Query class: AddPrompt method, Prompts property, QueryPrompt Class .

Click to jump to top of pageClick to jump to parent topicFormatBinaryResultString

Syntax

FormatBinaryResultString(&Rowset, Output_Format, Start_Row, End_Row)

Description

Use the FormatBinaryResultString method to generate a string containing the content of the input (the rowset) in XLS format. You can specify the range of rows to be in the rowset to be used as input. The rowset object is created using the RunToRowset method.

Parameters

&Rowset

Specify an already instantiated and populated rowset object containing the query result. This rowset is created using the RunToRowset method.

Output_Format

Specify the format of the output. You can specify either a numeric or constant value. See below.

Start_Row

Specify the first row in the rowset that you want to use for output. This parameter takes a numeric value.

End_Row

Specify the last row in the rowset that you want to use for output. This parameter takes a numeric value.

The values for Output_Format can be as follows:

Numeric Value

Constant Value

Description

8

%Query_XLS

The output for Excel in HTML format.

Returns

A binary object containing the formatted output.

Example

/* Use RowCount, not ActiveRowCount, to get the total number of rows. */ &End = &MyRowset.RowCount; &FormString = &MyQuery.FormatBinaryResultString (&MyRowset, %Query_XLS, 1, &End);

See Also

Query class: RunToFile method, RunToRowset method.

Click to jump to top of pageClick to jump to parent topicFormatResultString

Syntax

FormatResultString(&Rowset, Output_Format, StartRow, EndRow)

Description

Use the FormatResultString method to generate a string containing the content of the input (the rowset) in HTML, PDF, XLS, or CSV format. You can specify the range of rows to be in the rowset to be used as input. The rowset object is created using the RunToRowset method.

Parameters

&Rowset

Specify an already instantiated and populated rowset object containing the query result. This rowset is created using the RunToRowset method.

Output_Format

Specify the format of the output. You can specify either a numeric or constant value. See below.

Start_Row

Specify the first row in the rowset that you want to use for output. This parameter takes a numeric value.

End_Row

Specify the last row in the rowset that you want to use for output. This parameter takes a numeric value.

The values for Output_Format can be as follows:

Numeric Value

Constant Value

Description

2

%Query_PDF

The output is in PDF format.

5

%Query_HTML

The output is in HTML format.

8

%Query_XLS

The output for Excel in HTML format.

14

%Query_TXT

The output for text in CSV format.

20

%Query_XML_XmlP

The output is in XMLP format.

Returns

A string containing the formatted output.

Example

/* Use RowCount, not ActiveRowCount, to get the total number of rows. */ &End = &MyRowset.RowCount; &FormString = &MyQuery.FormatResultString(&MyRowset, %Query_TXT, 1, &End);

See Also

Query class: RunToFile method, RunToRowset method.

Click to jump to top of pageClick to jump to parent topicGetTreePromptCount

Syntax

GetTreePromptCount()

Description

Use the GetTreePromptCount method to get the number of tree prompts if available in the query.

Parameters

None.

Returns

A number that indicates the count of tree prompts used in the query. -1 in case of an error.

Example

In this example, the ExecQry step of the PSQUERY Application Engine program invokes the GetTreePromptCount() method using a value stored in the run control table prior to executing the query.

&aQry = %Session.GetQuery(); If &aQry.Open(PSQUERY_AET.QRYNAME, &bPublic, False) = 0 Then &nTreePromptCount = &aQry.GetTreePromptCount(); End-if;

Click to jump to top of pageClick to jump to parent topicOpen

Syntax

Open(QueryName, Public, Update)

Description

The Open method opens the query object specified by the parameters. The Open method can be used only with a closed query, it cannot be used on an open query. You cannot read or set any properties of a query until after you open it.

Considerations for Opening Different Types of Queries

When you use the Open method, the system tries to open queries according to the type of query. The following is the order used for searching for the query to open:

  1. Query (User)

  2. View

  3. Role

  4. Process

  5. Archive

All query names are unique. You can't have two queries with the same name, just of different types.

Parameters

QueryName

Specify the name of the query to be opened. You must specify an existing query. This parameter takes a string value.

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.

Update

This parameter is required, but is unused in this release. You must specify a either True or False.

Returns

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

See Also

GetQuery, Close, Save.

Click to jump to top of pageClick to jump to parent topicRename

Syntax

Rename(NewQueryName)

Description

The Rename method renames the existing query definition with NewQueryName. The Rename method can be used only with an open query, it cannot be used on a closed query. Before you use the Rename method, you must explicitly open the query object to be renamed (with either the Open or Create method.)

Note. The Rename method takes place immediately. You don't have to save the query for the rename to occur.

Parameters

NewQueryName

Specify the new name for the existing query. The maximum length of this parameter is 30 characters.

Returns

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

See Also

Query class: Open method, Close method, Save method.

Click to jump to top of pageClick to jump to parent topicRunToFile

Syntax

RunToFile(&PromptRecord, Destination, OutputFormat, MaxRows)

Description

Use the RunToFile method to execute the Query and return the result to the file specified with Destination. The query should be an existing query in the database, or it should have been saved using the Save method.

Because a Query may have runtime prompts (that is, criteria defined using Prompt), this method requires those values to be passed in when you execute this method. PromptRecord is a PeopleCode record object containing the prompt values as fields in the record. You can use the PromptRecord property to obtain this object.

Destination must include the absolute path name of where the file is to be created.

If the specified subdirectory does not exist, this method does not automatically create them for you, and you receive an error.

If you specify HTML as the output format, the PeopleSoft Query style sheet PSQUERYSTYLEDEF is used for formatting the output.

See Also

Creating Style Sheet Definitions.

Parameters

&PromptRecord

Specify an instance of a PeopleCode record that contains the runtime prompts and values required for running the query.

Destination

Specify the absolute path name of where the files are to be created.

OutputFormat

Specify the format of the data being written to the file. You can use either a constant or a numeric value for this parameter. See below.

MaxRows

Specify the maximum number of rows to be fetched. This parameter takes a numeric value.

The values are:

  • -1 returns all rows regardless of the setting on the Query security profile (MaxRowsFetched).

  • 0 returns the maximum number of rows allowed by the Query security profile.

  • >0 is the limit on the number of rows.

The values for OutputFormat can be as follows:

Numeric Value

Constant Value

Description

2

%Query_PDF

The output is in PDF format.

5

%Query_HTML

The output is in HTML format.

8

%Query_XLS

The output for Excel in HTML format.

14

%Query_TXT

The output for txt in CSV format.

17

%Query_XML_WebRowset

The output is in web rowset XML format.

20

%Query_XML_XmlP

The output is in XMLP format.

Returns

Returns 0 if successful.

Example

To run a query using the query API RunToFile method:

  1. Open the query.

    &aRunQry = %Session.GetQuery(); &aRunQry.Open(&sQryName, False, False);

  2. Obtain the PromptRecord for the query.

    &aQryPromptRec = &aRunQry.PromptRecord;

    This instance of the PromptRecord can be passed to the PeopleCode Prompt function to prompt the user for the runtime values, as follows:

    &nResult = Prompt(&strQryName | " Prompts", "", &aQryPromptRec);

  3. Run the query.

    Now that you have the runtime values, the query can be run, as follows:

    &aRowSet = &aRunQry.RunToFile(&aQryPromptRec, "c:\temp\QueryOutput.html", ⇒ %Query_PDF, 0);

  4. Access the data of the rowset.

    You can now manipulate the rowset using the data buffer access methods and properties:

    &aRowSet(&i).GetRecord(1).GetField(&j).Value

The following is a complete sample code example:

Local Rowset &aRowSet; Local Row &aRow; Local Record &aQryPromptRec; Local Record &aRec; Local ApiObject &aRunQry; &strHTML = ""; &aRunQry = %Session.GetQuery(); If (&aRunQry.Open(&sQryName, False, False) <> 0) Then &strHTML = "Error in opening query"; Else &aQryPromptRec = &aRunQry.PromptRecord; &strQryName = &aRunQry.Name; If &aQryPromptRec <> Null Then &nResult = Prompt(&strQryName | " Prompts", "", &aQryPromptRec); End-If; If (&aRunQry.RunToFile(&aQryPromptRec, "c:\temp\" | ⇒ &aRunQry.Name, 3, 0) = 0) Then &strHTML = "Resultset saved into file successfully."; Else &strHTML = "Failed to save Resultset into file."; End-If; End-If;

See Also

Query class: RunToRowset method, PromptRecord property.

Prompt

Accessing the Data Buffer

Click to jump to top of pageClick to jump to parent topicRunToRowset

Syntax

RunToRowset(&PromptRecord, MaxRows)

Description

Use the RunToRowset method to execute the Query and return the result to a rowset. The query should be an existing query in the database, or it should have been saved using the Save method.

Because a Query may have runtime prompts (that is, criteria defined using Prompt), this method requires those values to be passed in when you execute this method. PromptRecord is a PeopleCode record object containing the prompt values as fields in the record. The PromptRecord property can be used to obtain this object.

Parameters

&PromptRecord

Specify an instance of a PeopleCode record that contains the runtime prompts and values required for running the query.

MaxRows

Specify the maximum number of rows to be fetched. This parameter takes a numeric value. The total number of rows fetched is the minimum value of this parameter's value, and the application server configuration parameter Max Fetch Size (which is specified in KB.)

The values are:

  • -1 returns all rows regardless of the setting on the Query security profile (MaxRowsFetched).

  • 0 returns the maximum number of rows allowed by the Query security profile.

  • >0 is the limit on the number of rows.

Returns

If successful, the query result is returned as a populated PeopleCode rowset. If the query wasn't successful, the method returns NULL. If unsuccessful, check the PSMessages collection for errors.

Example

To run a query using the query API RunToRowset method:

  1. Open the Query.

    &aRunQry = %Session.GetQuery(); &aRunQry.Open(&sQryName, False, False);

  2. Get the PromptRecord for the Query.

    &aQryPromptRec = &aRunQry.PromptRecord;

    This instance of the PromptRecord can be passed to the PeopleCode Prompt function to prompt the user for the runtime values, as follows:

    &nResult = Prompt(&strQryName | " Prompts", "", &aQryPromptRec);

  3. Run the query.

    Now that you have the prompt values, you can run the query:

    &aRowSet = &aRunQry.RunToRowset(&aQryPromptRec, 0);

  4. Access the data of the rowset.

    You can now manipulate the rowset using the data buffer access methods and properties:

    &aRowSet(&i).GetRecord(1).GetField(&j).Value

The following is a complete sample code example:

Local Rowset &aRowSet; Local Row &aRow; Local Record &aQryPromptRec; Local Record &aRec; Local ApiObject &aRunQry; &strHTML = ""; &aRunQry = %Session.GetQuery(); If (&aRunQry.Open(&sQryName, False, False) <> 0) Then &strHTML = "Error in opening query"; Else &aQryPromptRec = &aRunQry.PromptRecord; &strQryName = &aRunQry.Name; If &aQryPromptRec <> Null Then &nResult = Prompt(&strQryName | " Prompts", "", &aQryPromptRec); &aRowSet = &aRunQry.RunToRowset(&aQryPromptRec, 0); If &aRowSet <> Null Then &strHTML = &strHTML | "<table cellpadding='2' ⇒ cellspacing='0' width='90%'>"; &aRec = &aRowSet(1).GetRecord(1); &QrySelOutputFldCol = &aRunQry.QuerySelect.QueryOutputFields; If &QrySelOutputFldCol <> Null Then &strHTML = &strHTML | "<TR><TD>"; &strHTML = &strHTML | "<table border='1' cellpadding='2'⇒ cellspacing='0' width='100%'>"; &strHTML = &strHTML | "<TR><TH>&nbsp;</TH>"; For &j = 1 To &QrySelOutputFldCol.count &strHTML = &strHTML | "<TH><B>" | &QrySelOutputFldCol.Item⇒ (&j).LongName | "</B></TH>"; End-For; &strHTML = &strHTML | "</TR>"; &strHTML = &strHTML | "</TD></TR>"; End-If; &strHTML = &strHTML | "<TR><TD>"; If &aRowSet.RowCount > 0 Then For &i = 1 To &aRowSet.RowCount &aRow = &aRowSet(&i); &strHTML = &strHTML | "<TR>" | "<TD>" | &i | "</TD>"; For &j = 1 To &aRow.GetRecord(1).FieldCount &strHTML = &strHTML | "<TD>" | &aRow.GetRecord(1).GetField⇒ (&j).Value | "</TD>"; End-For; &strHTML = &strHTML | "</TR>"; End-For; Else &strHTML = &strHTML | "No records retrieved."; End-If; &strHTML = &strHTML | "</TD></TR>"; &strHTML = &strHTML | "</TABLE>"; &strHTML = &strHTML | "</TABLE>"; Else &strHTML = "Failed to retrieve result set."; End-If; End-If; End-If;

See Also

Query class: RunToFile method, PromptRecord property.

Prompt

Accessing the Data Buffer

Click to jump to top of pageClick to jump to parent topicRunToString

Syntax

RunToString(&PromptRecord, ChunkSize, OutputFormat, MaxRows)

Description

Use the RunToString method to execute the query and return the result as a formatted string.

When “chunking” is active, RunToString is intended to be called in a recursive fashion until the result set has been completely traversed. A Boolean property, MoreRowsAvailable, is included in the Query class to control recursive execution of this method.

See Query class: MoreRowsAvailable property.

Parameters

&PromptRecord

Specify an instance of a PeopleCode record that contains the runtime prompts and values required for running the query.

ChunkSize

Specify the desired chunking size in characters as a number. 0 means no chunking.

OutputFormat

Specify the format of the data being written to the file. You can use either a constant or a numeric value for this parameter. See below.

MaxRows

Specify the maximum number of rows to be fetched. This parameter takes a numeric value. The values are:

  • -1 returns all rows regardless of the setting on the query security profile (MaxRowsFetched).

  • 0 returns the maximum number of rows allowed by the query security profile.

  • >0 is the absolute limit on the number of rows.

The values for Output_Format can be as follows:

Numeric Value

Constant Value

Description

2

%Query_PDF

The output is in PDF format.

5

%Query_HTML

The output is in HTML format.

8

%Query_XLS

The output for Excel in HTML format.

14

%Query_TXT

The output for text in CSV format.

17

%Query_XML_WebRowset

The output is in web rowset XML format.

20

%Query_XML_XmlP

The output is in XMLP format.

Returns

A string containing the formatted output. If an error occurs, an empty string will be returned.

If there are no errors, but no data is in the query result set, the string will have system-defined header and footer information, but no rows will be present.

Example

The following example runs a query without chunking.

&queryname = "XRFWIN"; rem &querytype = %Query_XLS; rem &querytype = %Query_PDF; rem &querytype = %Query_HTML; rem &querytype = %Query_TXT; &querytype = %Query_XML_XmlP; rem &querytype = %Query_XML_WebRowset; &aRunQry = %Session.GetQuery(); If (&aRunQry.Open(&queryname, False, False) <> 0) Then MessageBox(0, "", 0, 0, "Error opening query"); Else &aQryPromptRec = &aRunQry.PromptRecord; &chunksize = 0; &filename = "C:\QueryWork850\output\" | &querytype | "_runtostring.xml"; &resultString = &aRunQry.RunToString(&aQryPromptRec, &chunksize, &querytype, 0); &myfile = GetFile(&filename, "w", %FilePath_Absolute); &myfile.writestring(&resultString); &myfile.close(); MessageBox(0, "", 0, 0, "Success!"); End-If;

The following example runs a query with chunking.

&queryname = "XRFWIN"; rem &querytype = %Query_XLS; rem &querytype = %Query_PDF; rem &querytype = %Query_HTML; rem &querytype = %Query_TXT; &querytype = %Query_XML_XmlP; rem &querytype = %Query_XML_WebRowset; &aRunQry = %Session.GetQuery(); If (&aRunQry.Open(&queryname, False, False) <> 0) Then MessageBox(0, "", 0, 0, "Error opening query"); Else &aQryPromptRec = &aRunQry.PromptRecord; &counter = 0; &chunksize = 1000; Repeat &counter = &counter + 1; &filename = "C:\QueryWork850\output\" | &querytype | &counter | ⇒ "_runtostring.xml"; &resultString = &aRunQry.RunToString(&aQryPromptRec, &chunksize, ⇒ &querytype, 0); If (Len(&resultString) > 0) Then &myfile = GetFile(&filename, "w", %FilePath_Absolute); &myfile.writestring(&resultString); &myfile.close(); Else /* edge condition; if there are no more rows AND the */ /* returned string is empty this is not an error. */ If (&aRunQry.MoreRowsAvailable) Then /* we have an error... Yikes! */ MessageBox(0, "", 0, 0, "Something bad has happened!"); Else /* no worries, just ignore it */ End-If; End-If Until (Not &aRunQry.MoreRowsAvailable); MessageBox(0, "", 0, 0, "Success!"); End-If;

See Also

MoreRowsAvailable

Click to jump to top of pageClick to jump to parent topicSave

Syntax

Save()

Description

The Save method writes any changes to the existing query to the database.

The Save method can be used only on an open query, not on a closed query. This means you must have opened the query with the Open method before you can save it.

The query object remains open after executing Save. You must execute the Close method on the object before it is closed and the memory freed.

Note. If you’re calling the query API from an Application Engine program, the data won’t actually be committed to the database until the Application Engine program performs a COMMIT.

Parameters

None.

Returns

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

See Also

Query class: Open method, Close method.

Click to jump to top of pageClick to jump to parent topicSetTrackingURL

Syntax

SetTrackingURL(ExpressionText, ExpressionNumber)

Description

Use the SetTrackingURL method to re-establish the drilling URL if the current execution context is different from the context in which the drilling URL was initially set.

For example, a drilling URL is set as a query expression by the program that executes the query. After query execution, a different program—an iScript program—allows the user to download the query results to an Excel spreadsheet. This iScript program needs to include the drilling URL in the spreadsheet data. In order for the iScript program to have access to the drilling URL query expression values, these values must be defined as global objects by the program that executes the query. Then, the iScript program can re-establish the drilling URL by calling the SetTrackingURL method.

Parameters

ExpressionText

Specify the drilling URL as a string by reference to an established query expression.

ExpressionNumber

Specify the drilling URL as a numeric value by reference to an established query expression.

Returns

None.

Example

If &rsURLList <> Null And &rsURLList.ActiveRowCount >= 1 And All(&rsURLList(1).QRY_URL_WRK.QRYCRIT1EXPRTEXT.Value) Then For &nCount = 1 To &rsURLList.ActiveRowCount; &rRecordExpr = &rsURLList(&nCount).QRY_URL_WRK; &QryObj.SetTrackingURL(&rRecordExpr.QRYCRIT1EXPRTEXT.Value, ⇒ &rRecordExpr.QRYCRIT1EXPRNUM.Value); End-For; End-If;

See Also

AddTrackingURL

Setting a Drilling URL

Drilling URL in Oracle PeopleSoft Query

Click to jump to parent topicQuery Class Properties

In the following section, we discuss each Query class property.

Click to jump to top of pageClick to jump to parent topicApproved

Description

This property returns a string indicating whether a query is approved, unapproved, or modified. This is useful for query administration. The values are:

Value

Description

U

Query is unapproved. This is the default value. The query administrator can prevent execution of unapproved queries.

A

Query has been approved by the query administrator.

M

Query has been modified.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicApproveOprId

Description

Note. This property has been deprecated, and remains for backward compatibility only. Use the ApproveUserId property instead.

This property returns a string containing the user ID of the user who approved the query. This can be useful for query administration.

This property is read-write.

See Also

Query class: ApproveUserId property.

Click to jump to top of pageClick to jump to parent topicApproveUserId

Description

This property returns a string containing the user ID of the user who approved the query. This can be useful for query administration.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicApproveDtTm

Description

This property returns the date-time stamp when the query was most recently approved. This can be useful for query administration.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCreateOprId

Description

Note. This property has been deprecated, and remains for backward compatibility only. Use the CreateUserId property instead.

This property returns a string containing the User Id of the user who created the query. This can be useful for query administration.

This property is read-only.

See Also

Query class: CreateUserId property.

Click to jump to top of pageClick to jump to parent topicCreateDtTm

Description

This property returns a string containing the date-time stamp indicating when the query was created. This property is set by the query runtime when a new query is saved. This can be useful for query administration.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCreateUserId

Description

This property returns a string containing the User Id of the user who created the query. This can be useful for query administration.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicDescription

Description

This property returns or sets the short description for the query.

The length of this property is 30 characters.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicDisabled

Description

This property indicates if the query is active or not. This property returns a string value:

Value

Description

Y

This query is not active

Blank or any other value

This query is active

This property is read-write.

Click to jump to top of pageClick to jump to parent topicExecAppName

Description

This property specifies the name of the application executing the query. This property isn't required. This means this property is used only if the query will be executed. This name is stored in the query execution log. This property returns a blank value when the query is opened.

When executing a query using the query API, this property should be set to the Application name that's executing it, so that the Query Monitor can track query execution. Doing this makes this property useful for query administration. If you try to read this property before setting it, you receive a NULL string.

This property should be set before using RunToRowset or RunToFile.

This property is read-write. However, this property is generally used only to set the name, rather than to read it.

Click to jump to top of pageClick to jump to parent topicExecLogging

Description

This property indicates whether an execution log should be created when the query is executed. This can be useful for query administration. This property takes a Boolean value: True, create a log, False, don't create one.

The execution log, which is created by setting this property, can be viewed from the Query Monitor. The logging is done in a PeopleSoft Table. It stores, along with other relevant information, the Execution DateTime, Total Execution Time for the query, and Total Fetch Time for the query.

If you try to read this property before setting it, you receive a NULL string.

This property is read-write. However, this property is generally used only to set logging, rather than read.

Click to jump to top of pageClick to jump to parent topicFolder

Description

This property is used to group queries together. This parameter takes a string value, up to 18 characters.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicLastSQLErrorCode

Description

This property returns the last SQL error code returned by the database as a number. The session object contains the error text and any other errors encountered while executing the query.

PeopleSoft recommends checking this value after using RunToRowset or RunToFile.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLastUpdDttm

Description

This property returns the most recent date-time when the query was updated as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLastUpdOprId

Description

This property returns the User Id of the user who updated the query most recently as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLongDescription

Description

This property returns or sets the long description for the query.

The length of this property is 256 characters.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicMetadata

Description

This property returns a metadata collection.

This property is read-only.

Example

&MetadataList = &MyQuery.Metadata;

See Also

Query Metadata Collection.

Click to jump to top of pageClick to jump to parent topicMetaSQL

Description

This property returns the SQL that represents the query, unresolved for any platform.

For example, the MetaSQL property returns the following:

SELECT %DATEOUT(A.ASOF_DT) FROM PS_AEREQUESTTBL A WHERE A.ASOF_DT = %DATEIN('1900-01-01')

This property is read-only.

Click to jump to top of pageClick to jump to parent topicMoreRowsAvailable

Description

This property returns a Boolean value indicating whether “chunking” is turned on for the query.

This property is read-only.

Chunking Considerations

Every time a row is retrieved from the query result set, it is added to the internal output string managed by RunToString. At this point, the method can check to see if chunking is active. If so, and if the current size of the output string is larger than the ChunkSize parameter, then the query context is stored and the output string is returned. If not, then the next row is retrieved from the result set and the process continues.

When chunking is active, RunToString is intended to be called in a recursive fashion until the result set has been completely traversed. A Boolean property, MoreRowsAvailable, is included in the Query class to control recursive execution of these methods.

See Also

RunToString, .

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the query as a string.

The length of this property is 30 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicOutputUnicode

Description

Use this property to set or return a Boolean value indicating whether the RunToFile method will create a Unicode-encoded CSV file as output. This property is applicable only if the output format is set to %Query_TXT. Because the default value is false, OutputUnicode must be set before calling RunToFile.

Note. Because Microsoft Excel does not support UTF-8 encoding, the CSV file is written in binary mode with UCS-2 encoded data. Moreover, Excel does not automatically recognize Unicode-encoded, comma-delimited files even if they have a .csv extension. Therefore, the user receiving the file will not be able to open it by double-clicking. Instead, he or she must open it with Excel’s File, Open menu and choose the comma delimiter.

This property is read-write.

Example

&aQry.OutputUnicode = True; &Result = &aQry.RunToFile(&rcdQryPrompts, &sOutFile, %Query_TXT, 0);

See Also

RunToFile

Click to jump to top of pageClick to jump to parent topicPDFFont

Description

This property is used to set the PDF Font number required for generating PDF using RunToFile. This property takes either a numeric or constant value. The values are:

Numeric Value

Constant Value

Description

0

%PDFFont_None

Default value

2

%PDFFont_TraditionalChinese

The output must be written using the Traditional Chinese Font.

3

%PDFFont_SimplifiedChinese

The output must be written using the Simplified Chinese Font.

1

%PDFFont_Japanese

The output must be written using the Japanese Font

4

%PDFFont_Korean

The output must be written using the Korean Font

If you try to read this property before setting it, you receive a NULL string.

This property is read-write.

See Also

Query class: RunToFile method, RunToRowset method.

Click to jump to top of pageClick to jump to parent topicPrompts

Description

This property returns all the prompts defined for the Query in a QueryPrompt Collection. If you just want the prompts used in the criteria, use the RunTimePrompts property.

This property is read-only.

See Also

RunTimePrompts, QueryPrompt Collection.

Click to jump to top of pageClick to jump to parent topicPromptRecord

Description

This property returns the runtime prompts of a query as an instance of a PeopleCode record object. This can be used with the Prompt built-in function to prompt for bind values. This record instance can also be used as the first input parameter for the RunToRowset and RunToFile methods.

This property is read-only.

See Also

Query class: RunToFile method, RunToRowset method.

Click to jump to top of pageClick to jump to parent topicPublicPrivate

Description

This property specifies whether the query is public or private.

You can use either a constant or numeric value for this property. The values are:

Numeric Value

Constant Value

Description

0

%Query_Private

The query is a private query.

1

%Query_Public

The query is a public query.

This property is read-write.

Example

If &QryObj.PublicPrivate = %Query_Public Then /* code when working with Public Query */ Else /* code when working with Private Query */ End-if;

Click to jump to top of pageClick to jump to parent topicQuerySelect

Description

This property returns the Main Select (that is, the first select) of the query definition as a QuerySelect object. For a new query which does not have any selects, it returns NULL.

The Query Records, Query Criteria, QueryOutput fields, and QuerySelected Fields can be obtained using the QuerySelect object only. Hence, after opening a query, this property serves as the starting point for getting the different components of the Select statement.

This property is read-only.

See Also

QuerySelect Class.

Click to jump to top of pageClick to jump to parent topicQueryStatistics

Description

This property returns statistical information pertaining to the query’s execution as a QueryStatistics object.

This property is read-only.

See Also

QueryStatistics Class.

Click to jump to top of pageClick to jump to parent topicRunTimePrompts

Description

This property returns the prompts used in the Query Definition’s criteria in a QueryPrompt Collection. To return all the prompts defined for the query, use the Prompts property.

This is property is read-only.

See Also

Prompts, QueryPrompt Collection.

Click to jump to top of pageClick to jump to parent topicSQL

Description

This property returns the SQL statement as generated from the query definition as a character string.

Note. The value of the SQL property is never stored as part of the query definition. Instead, it's generated by the system whenever it's needed for one of the RunTo methods or for the SQL property.

In the PeopleSoft Query, this is located under the SQL tab.

This property is read-only.

Considerations Using the SQL Property

This property returns a basic SQL statement. This statement does not include logic for doing related language record transactions or translate descriptions. PeopleSoft does not recommend using this SQL for selecting data. Instead, PeopleSoft recommends using the RunToRowset method for selecting data.

Click to jump to top of pageClick to jump to parent topicType

Description

This property specifies the type of query. This parameter takes either a constant or number value. Values are:

Numeric Value

Constant Value

Description

1

%Query_Query

Query of type Query

3

%Query_View

Query of type View

4

%Query_Role

Role

5

%Query_DBAgent

Process

7

%Query_Archive

Archive

This property is read-write.

Click to jump to parent topicQuerySelect Collection

A QuerySelect collection is returned from the QuerySelects property of each QuerySelect instance. It contains the unions and subqueries, which are children of the current select statement. PeopleSoft Query allows unions only for the main select. The QuerySelect instance for any subqueries cannot have any unions.

See QuerySelect class: QuerySelects property.

Click to jump to parent topicQuerySelect Collection Methods

In this section, we discuss the QuerySelect collection methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAddUnion

Syntax

AddUnion()

Description

The AddUnion method adds a new QuerySelect object of type Union in the current QuerySelect collection. You can use AddUnion only with the first QuerySelect Collection because PeopleSoft Query doesn’t' support Unions for subqueries. All unions are considered children of the Main Select.

Parameters

None.

Returns

A reference to a QuerySelect object if successful. If the current QuerySelect Collection does not belong to the first Select statement, it returns NULL. If it fails, it returns NULL.

Example

&QryMainSel = &Query.QuerySelect; &QryMainSelCol = &QryMainSel.QuerySelects; &QryUnion = &QryMainSelCol.AddUnion();

Click to jump to top of pageClick to jump to parent topicDeleteQuerySelect

Syntax

DeleteQuerySelect(SelNumber)

Description

The DeleteQuerySelect method deletes the QuerySelect instance represented SelNumber.

Parameters

SelNumber

Specify the numeric value containing the Select Number of the QuerySelect that you want to delete.

Returns

Returns 0 if successful.

Example

&QryMainSel = &Query.QuerySelect; &QryMainSelCol = &QryMainSel.QuerySelects; &QryMainSelCol.DeleteQuerySelect(3);

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

The First method returns the first child QuerySelect object in the current QuerySelect’s collection.

Parameters

None.

Returns

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

Example

&MyChildQrySel = &MySelCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemBySelNum

Syntax

ItemBySelNum(SelNumber)

Description

The ItemBySelNum method returns the QuerySelect object specified by the Select Number. Each Select Statement in a Query Definition is identified by a unique select number.

Parameters

SelNumber

Specify the numeric value of the Select Number.

Returns

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

Example

&MyChildQuerySelect = &MySelCol.ItemBySelNum(3);

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QuerySelect object in the current QuerySelect collection. You can use this method only after you have used the First method: otherwise the system returns a NULL.

Parameters

None.

Returns

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

Example

&MyChildQuerySelect = &MySelCol.Next();

Click to jump to parent topicQuerySelect Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the total number of QuerySelect objects in the current QuerySelect Collection, as a number.

This property is read-only.

Example

&COUNTCHILDSELS = &MYSELCOL.Count;

Click to jump to parent topicQuerySelect Class

The QuerySelect class represents the select statement of the SQL used in the query definition. This can be any of the following:

Consider the following SQL statement:

select ACCOUNT_NUM from GL_ACCOUNT_TBL_00 where PRODUCT_ID in (select DISTINCT PRODUCT_ID FROM ORDER_TBL) union select ACCOUNT_NUM from GL_ACCOUNT_TBL_01

In this example, there are three select statements. The first select statement is the main statement. The second select statement is a subquery, which is then used in the criterion for the first select statement. The union contains the third select statement. There are records and fields associated with each select statement. In the query API, the first select is accessible using Query.QuerySelect, which can be obtained as shown:

&MainSelect = &Qry.QuerySelect;

The union can be obtained from the main select, as shown:

/* There can be more than one union, hence there is collection of selects */ /* in the main select */ &Union1 = &MainSelect.QuerySelects.Item(1);

The subquery is obtained from the main select as shown:

/* belongs to first criteria of the select */ &SubQry1 = &MainSelect.Criteria.Item(1).Expr2SubQuery;

Therefore, there is one QuerySelect instance for the main select of the query, one instance per union defined in the query, and one instance per subquery.

In PeopleSoft Query, the first select (that is, the main select) is the parent of all the unions and subqueries. The main select is obtained with the QuerySelect property. The unions and subqueries are obtained from the QuerySelects property of each QuerySelect instance.

A QuerySelect object is returned from the following:

See QuerySelect Collection, QuerySelects.

Click to jump to parent topicQuerySelect Methods

In this section, we discuss each QuerySelect method. The methods are arranged in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAddAllFields

Syntax

AddAllFields(QueryRecord)

Description

The AddAllFields method adds all the fields in the specified query record to the query definition, that is, makes them all QueryOutputFields. The query record must already be a part of the query definition.

Parameters

QueryRecord

Specify the instance of an existing record in the query from which you want to add all the fields from to the query definition. This instance can be obtained from the QueryRecords collection of the QuerySelect.

Returns

An integer: 0 if successfully added.

See Also

QuerySelect class: AddQueryOutputField method, AddQueryRecord method, AddQuerySelectedField method.

Click to jump to top of pageClick to jump to parent topicAddCriteria

Syntax

AddCriteria(Name)

Description

The AddCriteria method adds new criterion to the query definition. This method returns a reference to a new QueryCriteria object that you can then use to specify details about the criteria.

Note. If you do not specify a unique name for Name when adding a criteria, a criteria object referencing the new criteria is returned, not the existing criteria object.

Parameters

Name

Specify a string containing the name of the criteria that you want to add. The maximum length of this parameter is 30 characters.

Returns

A reference to a QueryCriteria object.

See Also

QuerySelect class: DeleteCriteria method, Criteria property, QueryCriteria Class .

Click to jump to top of pageClick to jump to parent topicAddExpression

Syntax

AddExpression(Name)

Description

The AddExpression method adds an expression to the query definition. It returns a reference to a new QueryExpression object you can use to specify details about the expression.

Parameters

Name

Specify a string containing the name of the expression that you want to add. This maximum length of this parameter is 30 characters.

Returns

A reference to a QueryExpression object.

See Also

FindExpression, DeleteExpression, Expressions, QueryExpression Class.

Click to jump to top of pageClick to jump to parent topicAddHavingCriteria

Syntax

AddHavingCriteria(Name)

Description

The AddHavingCriteria method adds new criterion to the query definition, which is intended for use in the HAVING clause of the SELECT statement. This method returns a reference to a new QueryCriteria object that you can then use to specify details about the having criteria.

Note. If you do not specify a unique name for Name when adding a criterion, a criteria object referencing the new criteria is returned, not the existing criteria object.

Parameters

Name

Specify a string containing the name of the criteria that you want to add. The maximum length of this parameter is 30 characters.

Returns

A reference to a QueryCriteria object.

See Also

QuerySelect class: DeleteHavingCriteria method, HavingCriteria property, QueryCriteria Class .

Click to jump to top of pageClick to jump to parent topicAddQueryOutputField

Syntax

AddQueryOutputField(QueryRecord, index)

Description

The AddQueryOutputField method adds a query output field to the query definition. This method returns a reference to a new QueryOutputField object that you can then use to specify attributes for the query definition.

Parameters

QueryRecord

Specify the QueryRecord instance that contains the field that you want to include in the query definition. This instance can be obtained from the QueryRecords collection of the QuerySelect.

Index

Specify the numeric position in the QueryRecord of the field that you want to add.

Returns

A reference to a QueryOutputField object.

See Also

AddAllFields, QueryField Class.

Click to jump to top of pageClick to jump to parent topicAddQueryRecord

Syntax

AddQueryRecord(QueryRecordName)

Description

The AddQueryRecord method adds a query record to the query definition. You must specify a valid record name in the string parameter QueryRecordName. This method returns a reference to the record as a QueryRecord.

Parameters

QueryRecordName

Specify a string containing the name of a record to be added to the query definition. You must specify a valid record name. The maximum allowed length for this parameter is 15 characters.

Returns

A reference to the record as a QueryRecord object.

See Also

QueryRecord Class.

Click to jump to top of pageClick to jump to parent topicAddQuerySelectedField

Syntax

AddQuerySelectedField(QueryRecordName, RecordAlias, FieldName, Heading)

Description

The AddQuerySelectedField method adds a query field to the query definition, as a QuerySelectedField. This method returns a reference to a new QuerySelectedField object that you can then use to specify attributes for the query definition. At the time it's added, it isn't an output field. This can be changed by setting the column number of the field to a value greater than zero.

Parameters

QueryRecordName

Specify the name of the query record to which the field that you want to add belongs.

RecordAlias

Specify the alias of the record (such as A, B, C, and so on.) The length of this parameter is 1.

FieldName

Specify the name of the field that's being added. The maximum allowed length for a field name is 18 characters.

Heading

Specify the heading of the field that's being added. The maximum allowed length for a heading is 30 characters.

Returns

A reference to a QuerySelectedField object.

See Also

QuerySelect class: AddAllFields method, DeleteField method, QueryField Class .

Click to jump to top of pageClick to jump to parent topicDeleteCriteria

Syntax

DeleteCriteria(index)

Description

The DeleteCriteria method deletes the criteria specified by index from the query definition.

Parameters

Index

Specify the numeric position in the query definition of the criteria that you want to delete.

Returns

An integer: 0 if successfully deleted.

See Also

QuerySelect class: AddCriteria method, Criteria property.

Click to jump to top of pageClick to jump to parent topicDeleteExpression

Syntax

DeleteExpression(index)

Description

The DeleteExpression method deletes the specified expression from the query definition.

Parameters

Index

Specify the numeric position of the expression in the query definition that you want to delete.

Returns

An integer: 0 if successfully deleted.

See Also

QuerySelect class: AddExpression method, Expressions property, QueryExpression Class .

Click to jump to top of pageClick to jump to parent topicDeleteField

Syntax

DeleteField(index)

Description

The DeleteField method deletes the selected field from the query definition. This does not delete the field from the QueryRecord, just from the query definition, so it's no longer selected.

Parameters

Index

Specify the position number of the field that you want deleted from the query definition.

Returns

An integer: 0 if successfully deleted.

See Also

AddAllFields, QueryField Class.

Click to jump to top of pageClick to jump to parent topicDeleteHavingCriteria

Syntax

DeleteHavingCriteria(index)

Description

The DeleteHavingCriteria method deletes the having criteria specified by index from the query definition.

Parameters

Index

Specify the numeric position in the query definition of the having criteria that you want to delete.

Returns

An integer value: 0 means the having criteria was deleted successfully.

See Also

QuerySelect class: AddHavingCriteria method, HavingCriteria property.

Click to jump to top of pageClick to jump to parent topicDeleteRecord

Syntax

DeleteRecord(index)

Description

The DeleteRecord method deletes the selected record from the query definition. This does not delete the record from the database or the QueryDBRecord collection, just from the query definition, so it's no longer selected.

Parameters

Index

Specify the position number of the record you want deleted from the query definition.

Returns

An integer: 0 if successfully deleted.

See Also

AddQueryRecord, QueryField Class.

Click to jump to parent topicQuerySelect Properties

In this section, we discuss the QuerySelect properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCriteria

Description

This property returns a reference to a QueryCriteria Collection for the simple criteria of the SELECT (that is, the criteria that are used in the where clause of the select statement.)

This property is read-only.

See Also

QueryCriteria Collection.

Click to jump to top of pageClick to jump to parent topicDistinct

Description

This property specifies if the Select is distinct or not.

This property takes a Boolean value: True if the query is distinct, False if the query isn't distinct.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicExpressions

Description

This property returns a reference to a QueryExpression Collection.

This property is read-only.

See Also

QueryExpression Collection.

Click to jump to top of pageClick to jump to parent topicHavingCriteria

Description

This property returns a reference to a QueryCriteria collection populated with Having criteria.

This property is read-only.

See Also

QueryCriteria Collection.

Click to jump to top of pageClick to jump to parent topicParentSelectNum

Description

This property returns the select number of the parent select of the current select object. Every QuerySelect is assigned a unique number indicating its place in the hierarchy of select statements. For the Main Select, this number is zero. For unions, this number is 1 (unions aren't allowed in subqueries.)

This property is read-only.

Click to jump to top of pageClick to jump to parent topicQueryOutputFields

Description

This property returns a reference to a QueryField Collection made up of QueryOutputFields.

The collection of QueryOutputFields does not necessarily include all columns returned in query resultset. This collection only includes columns that have been added to query output collection using the query classes or by an end-user designing a query.

PeopleSoft Query can also add additional columns for related language processing and also for translate labels on fields, and so you cannot use the Query Output Collections as a way to discover all of the columns that are returned in the resultset or by executing the SQL generated from a query.

This is property is read-only.

See Also

QueryField Collection.

Click to jump to top of pageClick to jump to parent topicQueryRecords

Description

This property returns a reference to a QueryRecord Collection for the query.

This is property is read-only.

See Also

QueryRecord Collection.

Click to jump to top of pageClick to jump to parent topicQuerySelectedFields

Description

This property returns a reference to a QueryField Collection made up of QuerySelectedFields.

This is property is read-only.

See Also

QueryField Collection.

Click to jump to top of pageClick to jump to parent topicQuerySelects

Description

This property returns all the QuerySelect objects that are children of the current select statement as a QuerySelect collection. If the query contains unions, this property contains unions and subqueries (if any criteria contain subqueries). For all other selects, this property contains only the subqueries (because PeopleSoft Query doesn't allow unions for sub-queries).

This is property is read-only.

See Also

QuerySelect Collection.

Click to jump to top of pageClick to jump to parent topicSelectNum

Description

This property returns the select number of the current select. Every QuerySelect is assigned a unique number indicating its place in the hierarchy of select statements. For the Main Select, this number would be 1.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicSelectType

Description

This property specifies what type of select statement. You can check for either a numeric or a constant value. The values are:

Numeric Value

Constant Value

Description

1

%Query_SelectMain

This is the Main Select of the query definition.

2

%Query_SubQuery

This is a subquery in the query definition.

3

%Query_Union

This is a Union in the query definition.

This property is read-only.

Click to jump to parent topicQueryRecord Collection

A QueryRecord collection is returned from the QueryRecords QuerySelect class method.

See QuerySelect class: QueryRecords property.

Click to jump to parent topicQueryRecord Collection Methods

In this section, we discuss each QueryRecord collection method. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryRecord = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByAlias

Syntax

ItemByAlias(Alias)

Description

The ItemByAlias method returns the QueryRecord object specified by Alias.

Parameters

Alias

Specify the record alias (for example, A, B, C, and so on), used in the SQL statement as a TableName alias.

Returns

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

Example

&MyQueryRecord = &MyCollection.ItemByAlias("A");

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryRecord object in the QueryRecord 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 QueryRecord object if successful, NULL otherwise.

Example

&MyQueryRecord = &MyCollection.Next();

Click to jump to parent topicQueryRecord Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryRecord objects in the QueryRecord Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryRecord Class

A QueryRecord object is returned from the following:

See QueryRecord Collection, AddQueryRecord, QueryRecord.

Click to jump to parent topicQueryRecord Class Method

In this section, we discuss the GetField method.

Click to jump to top of pageClick to jump to parent topicGetField

Syntax

GetField(Index)

Description

The GetField method returns the QueryField object specified by index from the QueryRecord collection.

Parameters

Index

Specify the number of the field to be accessed.

Returns

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

Example

&QryFieldColl = &QryRec.QueryFields; For &I = 1 to &QryFieldColl.Count &QryField = &QryRec.GetField(&I); /* do processing */ End-For;

Click to jump to parent topicQueryRecord Class Properties

In this section, we discuss each QueryRecord class property. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicDescription

Description

This property returns the short description of the record as a string.

The length of this property is 30 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicJoinAlias

Description

This property returns or sets the join record’s alias, that is, A, B, C, and so on.

This is applicable in any type of join. The value is a string. The length of this property is 1 character.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicJoinFieldName

Description

This property returns or sets the join record’s field used in the join criteria. This is applicable in lookup-table joins. The value is a string.

The length of this property is 18 characters.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicJoinType

Description

This property returns or sets the join type. This is applicable in any type of join. You can use either a constant or numeric value.

The values for the join type are:

Numeric Value

Constant Value

Description

1

%Query_JoinNone

Query record isn't joined with any other record.

2

%Query_JoinHierarchy

Query record has a hierarchy join with another record.

3

%Query_JoinRelated

Query record has a lookup table join with another record.

4

%Query_JoinTree

Query record has a tree join with another record.

5

%Query_JoinLeftOuter

Query record has a left outer join with another record.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the record as a string.

The length of this property is 15 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicQueryFields

Description

This property returns a reference to a QueryField Collection that contains instances of all the fields belonging to the record definition.

This property is read-only.

See Also

QueryField Collection.

Click to jump to top of pageClick to jump to parent topicRecordAlias

Description

This property returns the alias used for the record in the query (that is, A, B, C, and so on.)

The length of this property is 1 character.

This property is read-write.

Click to jump to parent topicQueryField Collection

A QueryField collection is returned from the following:

The collection of QueryOutputFields does not necessarily include all columns returned in query resultset. This collection only includes columns that have been added to query output collection using the query classes or by an end-user designing a query.

PeopleSoft Query can also add additional columns for related language processing and also for translate labels on fields, and so you cannot use the Query Output Collections as a way to discover all of the columns that are returned in the resultset or by executing the SQL generated from a query.

See QueryOutputFields, QuerySelectedFields, QueryFields.

Click to jump to parent topicQueryField Collection Methods

In this section, we discuss each QueryField method. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryField = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByNameAndAlias

Syntax

ItemByNameAndAlias(Name, RecordAlias)

Description

The ItemByNameAndAlias method returns the QueryField object with the given Name and Record Alias.

Parameters

Name

Specify the name of an existing QueryField within the QueryField collection. If you specify an invalid name, the object is NULL.

RecordAlias

Alias of the record to which the field belongs

Returns

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

Example

&MyQueryField = &MyCollection.ItemByNameAndAlias("PHONELIST", "A");

Click to jump to top of pageClick to jump to parent topicItemByExpNum

Syntax

ItemByExpNum(ExpNum)

Description

The ItemByExpNum method returns the QueryField object with the given Expression Number, ExpNum.

Parameters

ExpNum

Expression Number for the given expression field. Non-expression fields have 0 value for the Expression Number.

Returns

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

Example

&QryFld = &QryFldCol.ItemByExpNum(1);

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryField object in the QueryField 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 QueryField object if successful, NULL otherwise.

Example

&MyQueryField = &MyCollection.Next();

Click to jump to parent topicQueryField Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryField objects in the QueryField Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryField Class

A QueryField object is returned by the following:

See QuerySelect class: AddQuerySelectedField method, AddQueryOutputField method.

See QueryField Collection.

Click to jump to parent topicQueryField Class Methods

In this section, we discuss each QueryField method. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAddTranslateExpression

Syntax

AddTranslateExpression(ExpressionName)

Description

Use the AddTranslateExpression method to add Translate Effective Date Logic expressions for translatable fields.

Parameters

ExpressionName

Specify the name of the expression name that you want to add.

Returns

A reference to a QueryExpression object.

See Also

QuerySelect class: Expressions property, DeleteExpression method, AddExpression method, AddTranslateField method, QueryExpression Class .

Click to jump to top of pageClick to jump to parent topicAddTranslateField

Syntax

AddTranslateField(FieldName)

Description

Use the AddTranslateField method to add a Translate Effective Date Logic field for a translatable field.

Parameters

FieldName

Specify the name of the translate field that you want to add. The maximum allowed length of this parameter is 18 characters.

Returns

A reference to a QueryField object.

See Also

QuerySelect class: Expressions property, DeleteExpression method, AddExpression method, AddTranslateExpression method, QueryExpression Class .

Click to jump to top of pageClick to jump to parent topicGetImageFormat

Syntax

GetImageFormat()

Description

Use the GetImageFormat method to differentiate between images and files, both stored as binary large objects (BLOBs) in the database.

Note. Because images and files share the field type value 8, this method is required to differentiate between the two types.

Parameters

None.

Returns

A number. A value 16 indicates that the field is of type file (or attachment).

See Also

Type

Click to jump to parent topicQueryField Class Properties

In this section, we discuss the QueryField class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAggregate

Description

This property returns or sets the aggregate type for the query field.

This property takes either a constant or numeric value. The values are:

Numeric Value

Constant Value

Description

1

%Query_TtlNone

Query field has no total

2

%Query_TtlSum

Query field is for Sum

3

%Query_TtlCount

Query field is for Count

4

%Query_TtlMin

Query field is for Minimum

5

%Query_TtlMax

Query field is for Maximum

6

%Query_TtlAvg

Query field is for Average

This property is read-write.

Click to jump to top of pageClick to jump to parent topicColumnNumber

Description

This property returns or sets the column number for the query field as a number. If the column number is greater than zero, the field is an output field.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicDescription

Description

This property returns the long description of the field as a string. This same value is returned by the Description property of the QueryDBRecordField class.

The length of this property is 30 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicDecimal

Description

This property returns the decimal positions QueryField as a number. This same value is returned by the Decimal property of the QueryDBRecordField class.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicExpNum

Description

This property returns or sets the Expression Number for the field. This value is 0 for non-expression fields. If the field is created for an expression, this value is the same as the expression number of the corresponding expression. This property takes a number value.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicFlag

Description

This property returns the Use Edit flag for the Query Field. It has the same values as returned by the Flag property of the QueryDBRecordField. This property takes a number value.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicFormat

Description

This property returns the field format for the query field. This property returns a string value. This property is useful for displaying the data type in a string format.

Values are:

Data Type

Value Returned

Character

“CHAR “

Long Character

"LONG CHAR "

Number

"NUMBER "

Signed number

"SIGNED "

Date

"DATE "

Time

"TIME "

Datetime

"DATE/TIME "

Image

"IMAGE "

This property is read-only.

Click to jump to top of pageClick to jump to parent topicHeadingText

Description

This property returns or sets the heading text for the query field as a string.

The length of this property is 30 characters.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicHeadingType

Description

This property returns or sets the heading type for the query field. This property takes either a numeric or constant value. The values are:

Numeric Value

Constant Value

Description

1

%Query_HdgNone

Query field has no heading.

2

%Query_HdgText

Query field has a text heading.

3

%Query_HdgRftShort

Query field uses the short RFT heading.

4

%Query_HdgRftLong

Query fields uses the long RFT heading.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicHeadingUniqueFieldName

Description

This property returns or sets the unique field name for the heading. The default value for this property is the record alias combined with the field name.

The length of this property is 30 characters.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicLength

Description

This property returns the length of the Query Field. The same value is returned by the Length property of the QueryDBRecordField. This property takes a numeric value.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLongName

Description

This property returns the long name of the Query Field. The same value is returned by the Long Name property of the QueryDBRecordField. This property takes a string value.

The length of this property is 30 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the query field as a string.

The length of this property is 18 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicOrderByDirection

Description

This property returns or sets the order by direction. This property takes a numeric value. The constants are the ASCII codes for space (" ") and "D".

Values are:

Numeric Value

Constant Value

Description

32

Code (" ")

Ascending

68

Code("D")

Descending

This property is read-write.

Example

The following sets the order by direction to be ascending.

&QueryField.OrderByDirection = Code(" ");

The following sets the order by direction to be descending.

&QueryField.OrderByDirection = Code("D");

Click to jump to top of pageClick to jump to parent topicOrderByNumber

Description

Use this property to specify whether a field is used as part of an 'Order By' statement in the SQL. The number value of this property indicates which is the first field in the order by statement, which is the second, and so on.

This property is read-write.

Example

To order a query by one field, you must set the OrderByNumber property for the other QueryFields as well, specifying the primary field as 1, the next field as 2, and so on.

&QryFld = &MainQrySel.AddQuerySelectedField("PSRECDEFN", "A", "RECNAME", ⇒ "Record Name"); &QryFld.ColumnNumber = 1; ​&QryFld.OrderByNumber = 1; ​ &QryFld = &MainQrySel.AddQuerySelectedField("PSRECDEFN", "A", "RECDESCR", ⇒ "Record Descr"); &QryFld.ColumnNumber = 2; ​&QryFld.OrderByNumber = 2; ​ &QryFld = &MainQrySel.AddQuerySelectedField("PSRECDEFN", "A", "RELLANGRECNAME",⇒ "Record Lang Rec"); &QryFld.ColumnNumber = 3; ​&QryFld.OrderByNumber = 3;

Click to jump to top of pageClick to jump to parent topicQueryRecord

Description

This property returns a reference to the QueryRecord containing this QueryField. If the field has no QueryRecord (that is, that this field is an expression field), this property returns NULL.

This property is read-only.

Example

&QryRcd = &QryFld.QueryRecord;

Click to jump to top of pageClick to jump to parent topicRecordAlias

Description

This property returns the record alias for the Query Field as a string. This value is usually a value like "A", "B", and so on. The same value is returned by the RecordAlias property for QueryRecord.

The length of this property is 1 character.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicShortName

Description

This property returns the short name of the Query Field. The same value is returned by the ShortName property for QueryDBRecordField. This property takes a string value.

The length of this property is 15 characters.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicTranslateEffDtLogic

Description

This property returns or sets the effective date logic for the QueryField.

The values are:

Numeric Value

Constant Value

Description

1

%Query_ExprCurDt

Current Date

2

%Query_ExprField

Field

3

%Query_Expression

Expression

This property is read-write.

Click to jump to top of pageClick to jump to parent topicTranslateExpression

Description

This property returns a reference to an expression object based on a translate field if the Translate Effective Date option refers to an Expression

This property is read-only.

See Also

QueryExpression Class.

Click to jump to top of pageClick to jump to parent topicTranslateField

Description

This property returns a reference to a QueryField object for a translate field if the Translate Effective Date Option refers to a field.

This property is read-only.

See Also

QueryField Class.

Click to jump to top of pageClick to jump to parent topicTranslateOption

Description

This property returns or sets the translate value for the QueryField. This property takes a numeric or constant value. The values are:

Numeric Value

Constant Value

Description

1

%Query_XlatNone

None

2

%Query_XlatShort

Short

3

%Query_XlatLong

Long

This property is read-write.

Click to jump to top of pageClick to jump to parent topicType

Description

This property returns the type of the field. You can use either a numeric or constant value. The values are:

Numeric Value

Constant Value

Description

0

%FieldType_Char

Character

1

%FieldType_LongChar

Long Character

2

%FieldType_Number

Number

3

%FieldType_SignedNumber

Signed number

4

%FieldType_Date

Date

5

%FieldType_Time

Time

6

%FieldType_DateTime

DateTime

8

%FieldType_Image

Image

8

%FieldType_File

File

9

%FieldType_ImageRef

ImageReference

Note. The Image and File types can be differentiated using the GetImageFormat method of the QueryField class.

This property is read-only.

See Also

GetImageFormat

Click to jump to parent topicQueryCriteria Collection

A QueryCriteria collection is returned from the Criteria QuerySelect class property.

See QuerySelect class: Criteria property.

Click to jump to parent topicQueryCriteria Collection Methods

In this section, we discuss the QueryCriteria collection methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryCriteria = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(CriteriaName)

Description

The ItemByName method returns the QueryCriteria object that exists with the passed CriteriaName in the QueryCriteria collection.

Parameters

CriteriaName

Specify the name of the Criteria to be searched. This name is the same as the one used while creating the criteria using QuerySelect.AddCriteria(CriteriaName).

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryCriteria object in the QueryCriteria 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 QueryCriteria object if successful, NULL otherwise.

Example

&MyQueryCriteria = &MyCollection.Next();

Click to jump to parent topicQueryCriteria Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryCriteria objects in the QueryCriteria Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryCriteria Class

A QueryCriteria object is returned from the following:

See QuerySelect class: AddCriteria method, AddHavingCriteria method.

See QueryCriteria Collection.

See Working With Query Criteria and Expressions.

See Defining Selection Criteria.

Click to jump to parent topicQueryCriteria Class Methods

In this section, we discuss the QueryCriteria class methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAddExpr1Expression

Syntax

AddExpr1Expression()

Description

The AddExpr1Expression method returns a reference to a new a QueryExpression object to be used as an expression for Expression 1. You can then use this object to specify details about the expression using the methods and properties of the QueryExpression Class.

Note. You must set the type for Expression 1 using the Expr1Type property before you can use this method.

Parameters

None.

Returns

A reference to a blank QueryExpression object.

See Also

QueryCriteria class: Expr1Expression property, AddExpr1Field method, Expr1Type property, QueryExpression Class .

Click to jump to top of pageClick to jump to parent topicAddExpr1Field

Syntax

AddExpr1Field(QueryRecordAlias, FieldName)

Description

The AddExpr1Field method returns a reference to a new a QueryField object to be used as a field for Expression 1. You can then use this object to specify details about the expression using the methods and properties of the QueryField Class.

Note. You must set the type for Expression 1 using the Expr1Type property before you can use this method.

Parameters

QueryRecordAlias

Specify the alias of the QueryRecord that contains the QueryField that you want to use.

FieldName

Specify the name of the QueryField in the QueryRecord that you want to use.

Returns

A reference to a blank QueryField object.

See Also

QueryCriteria class: Expr1Field property, AddExpr1Expression method, Expr1Type property, QueryField Class .

Click to jump to top of pageClick to jump to parent topicAddExpr2Expression

Syntax

AddExpr2Expression()

Description

The AddExpr2Expression method returns a reference to a new a QueryExpression object to be used as an expression for Expression 2. You can then use this object to specify details about the expression using the methods and properties of the QueryExpression Class.

Parameters

None.

Returns

A reference to a blank QueryExpression object.

See Also

QueryExpression Class.

Click to jump to top of pageClick to jump to parent topicAddExpr2Field1

Syntax

AddExpr2Field1(QueryRecordAlias, FieldName)

Description

Expression 2 has two field expressions because when the Between relational operator is used in a criteria, there can be two expression fields. The AddExpr2Field1 method returns a reference to a new QueryField object to be used as a field 1 for Expression 2. You can then use this object to specify details about the expression using the methods and properties of the QueryField Class.

Parameters

QueryRecordAlias

Specify the alias of the QueryRecord that contains the QueryField that you want to use.

FieldName

Specify the name of the QueryField in the QueryRecord that you want to use.

Returns

A reference to a blank QueryField object.

See Also

QueryRecord Class, QueryField Class.

Click to jump to top of pageClick to jump to parent topicAddExpr2Field2

Syntax

AddExpr2Field2(QueryRecordAlias, FieldName)

Description

Expression 2 has two field expressions because when the Between relational operator is used in a criteria, there can be two expression fields. The AddExpr2Field2 method returns a reference to a new a QueryField object to be used as a field 2 for Expression 2. You can then use this object to specify details about the expression using the methods and properties of the QueryField Class.

Parameters

QueryRecordAlias

Specify the alias of the QueryRecord that contains the QueryField that you want to use.

FieldName

Specify the name of the QueryField in the QueryRecord that you want to use.

Returns

A reference to a blank QueryField object.

See Also

QueryRecord Class, QueryField Class.

Click to jump to top of pageClick to jump to parent topicAddExpr2List

Syntax

AddExpr2List()

Description

Expression 2 can have a list of values when the Operator is of type In List (or Not In List). The AddExpr2List method returns a reference to a new QueryList, which can be used to add a list of values to the criteria.

Parameters

None.

Returns

A reference to a blank QueryList object.

See Also

QueryList Class.

Click to jump to top of pageClick to jump to parent topicAddExpr2Subquery

Syntax

AddExpr2Subquery()

Description

The AddExpr2Subquery method is used to create a subquery for Expression2. This method returns a new QuerySelect object you can use to specify details about the new subquery.

Warning! The new subquery created with this method replaces any existing subquery (for this criteria), destroying any existing properties or values.

Parameters

None.

Returns

A reference to a new QuerySelect object.

See Also

QuerySelect Class.

Click to jump to parent topicQueryCriteria Class Properties

In this section, we discuss the QueryCriteria class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicExpr1Expression

Description

This property returns a reference to the QueryExpression object that's used as Expression 1.

This property is valid only when Expression 1 exists as an expression. If you want to add an expression for Expression 1, use the AddExpr1Expression method.

This property is read-write.

See Also

QueryCriteria class: AddExpr1Expression method.

Click to jump to top of pageClick to jump to parent topicExpr1Field

Description

This property returns a reference to the QueryField object that's used as Expression 1.

This property is valid only when Expression 1 exists as a field. You can then use the QueryField Class methods and property to manipulate this object.

If you want to add a field for Expression 1, use the AddExpr1Field method.

This property is read-only.

See Also

QueryField Class, AddExpr1Field.

Click to jump to top of pageClick to jump to parent topicExpr1Type

Description

This property returns or sets the type for Expression 1.

Note. You must set the type of expression for every new criteria.

The values are:

Numeric Value

Constant Value

Description

2

%Query_ExprField

Field

3

%Query_Expression

Expression

This property is read-write.

Example

The following is used to test the expression to determine the property to use to retrieve it:

&MyExpr1 = &MyCrtColl.Next(); If &MyExpr1.Expr1Type = %Query_ExprField Then /* Expression is a Field */ &OldExpr1Value = &MyExpr1.Expr1Field; /* do processing */ Else /* Expression 1 is an expression */ &OldExpr1Value = &MyExpr1.Expr1Expression; /* Do processing */ End-if;

The following is an example showing how to add a field for Expression 1.

/* add a new criteria */ &MyCriteria = &MyQuery.AddCriteria(); /* set the type of the first expression to be a field */ ​&MyCriteria.Expr1Type = %Query_ExprField; ​/* add the field EMPLID from the ABSENCE_HIST record */ &MyField = &MyCriteria.AddExpr1Field("A", "EMPLID");

Click to jump to top of pageClick to jump to parent topicExpr2Constant1

Description

If the Between relational operator is used in the criteria, there can be two constants for Expression 2. This property returns or sets the constant value for the first constant for Expression 2. This property takes a string value.

This property is valid only when Expression 2 is defined as a constant.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicExpr2Constant2

Description

If the Between relational operator is used in the criteria, there can be two constants for Expression 2. This property returns or sets the constant value for the second constant for Expression 2. This property takes a string value.

This property is valid only when Expression 2 is defined as a constant.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicExpr2Expression1

Description

If the Between relational operator is used in the criteria, there can be two expressions for Expression 2. This property returns a reference to the first QueryExpression object that's used as Expression 2.

This property is valid only when Expression 2 exists as an expression. To add an expression for Expression 2, use the AddExpr2Expression method.

This property is read-write.

See Also

QueryCriteria class: AddExpr2Expression method.

Click to jump to top of pageClick to jump to parent topicExpr2Expression2

Description

If the Between relational operator is used in the criteria, there can be two expressions for Expression 2. This property returns a reference to the second QueryExpression object that's used as Expression 2.

This property is valid only when Expression 2 exists as an expression. To add an expression for Expression 2, use the AddExpr2Expression method.

This property is read-write.

See Also

QueryCriteria class: AddExpr2Expression method.

Click to jump to top of pageClick to jump to parent topicExpr2Field1

Description

If the Between relational operator is used in the criteria, there can be two fields for Expression 2. This property returns a reference to the first QueryField object that's used as Expression 2.

This property is only valid when Expression 2 exists as a field. You can then use the QueryField Class methods and property to manipulate this object.

To add a field for Expression 2, use the AddExpr2Field1 method.

This property is read-only.

See Also

AddExpr2Field1, QueryField Class.

Click to jump to top of pageClick to jump to parent topicExpr2Field2

Description

If the Between relational operator is used in the criteria, there can be two fields for Expression 2. This property returns a reference to the second QueryField object that's used as Expression 2.

This property is valid only when Expression 2 exists as a field. You can then use the QueryField Class methods and property to manipulate this object.

To add a field for Expression 2, use the AddExpr2Field2 method.

This property is read-only.

See Also

AddExpr2Field2, QueryField Class.

Click to jump to top of pageClick to jump to parent topicExpr2List

Description

This property returns a reference to the QueryList object of Expression 2 that's used when the Operator is of type In List (or Not In List).

This property is read-only.

Click to jump to top of pageClick to jump to parent topicExpr2Subquery

Description

This property returns a reference to the QuerySelect object that's used as a subquery for Expression 2.

This property is valid only when Expression 2 exists as a subquery. To add a subquery for Expression 2, use the AddExpr2Subquery method.

This property is read-only.

See Also

QueryCriteria class: AddExpr2Subquery method.

Click to jump to top of pageClick to jump to parent topicExpr2Type

Description

This property returns or sets the type for Expression 2. The following table lists all of possible values for this property. However, the values for this property are dependent upon the Operator property.

This property is read-write.

See Operator, Working With Query Criteria and Expressions.

You can use either a constant or numeric value for this property. The values are:

Numeric Value

Constant Value

Description

1

%Query_ExprConstant

Constant

2

%Query_ExprField

Field

3

%Query_Exprression

Expression

4

%Query_ExprSubQuery

Subquery

5

%Query_ExprList

List

6

%Query_ExprCurDt

Current date

7

%Query_ExprTree

Tree

8

%Query_ExprBind

Bind

9

%Query_ExprBothConst

The criterion's operator is Between and both values on the right-hand side are constants. (Const-Const)

10

%Query_ExprConstFld

The criterion's operator is Between, the first value on right-hand side is a constant and the second value is a field. (Const-Field)

11

%Query_ExprConstExpr

The criterion's operator is Between, the first value on right-hand side is a constant and the second value is an expression. (Const-Expr)

12

%Query_ExprFieldConst

The criterion's operator is Between, the first value on right-hand side is a field and the second value is a constant. (Field-Const)

13

%Query_ExprBothFld

The criterion's operator is Between and both values on the right-hand side are constants. (Field-Field)

14

%Query_ExprFldExpr

The criterion's operator is Between, the first value on right-hand side is a field and the second value is an expression. (Field-Expr)

15

%Query_ExprExprConst

The criterion's operator is Between, the first value on right-hand side is an expression and the second value is a constant. (Expr-Const)

16

%Query_ExprExprFld

The criterion's operator is Between, the first value on right-hand side is an expression and the second value is a field. (Expr-Field)

17

%Query_ExprBothExpr

The criterion's operator is Between and both values on the right-hand side are expressions. (Expr-Expr)

18

%Query_ExprTreePrompt

Tree prompt

The following table describes how to access or change Expression 2 depending on the Expression2 Type.

Expression2 Type

Method or Property for Changing the Expression

Method or Property for Accessing the Expression

Constant

Expr2Constant

Expr2Constant

Field

AddExpr2Field()

Expr2Field

Expression

AddExpr2Expression()

Expr2Expression

In List

AddExpr2List

Expr2List

In Tree

AddExpr2Expression

Expr2Expression

Subquery

AddExpr2Subquery()

Expr2Subquery

Const-Const

Expr2Constant,

Expr2Constant

Expr2Constant,

Expr2Constant

Const-Field

Expr2Constant,

AddExpr2Field()

Expr2Constant,

Expr2Field

Const-Expr

Expr2Constant,

AddExpr2Expression()

Expr2Constant,

Expr2Expression

Field-Const

AddExpr2Field(),

Expr2Constant

Expr2Field,

Expr2Constant

Field-Field

AddExpr2Field(),

AddExpr2Field()

Expr2Field,

Expr2Field

Field-Expr

AddExpr2Field(),

AddExpr2Expression()

Expr2Field,

Expr2Expression

Expr-Const

AddExpr2Expression(),

Expr2Constant

Expr2Expression,

Expr2Constant

Expr-Field

AddExpr2Expression(),

AddExpr2Field()

Expr2Expression,

Expr2Field

Expr-Expr

AddExpr2Expression(),

AddExpr2Expression()

Expr2Expression,

Expr2Expression

Example

The following is used to test the expression to determine the property to use to retrieve it:

&MyExpr2 = &MyCriteria.Expr2Expression; If &MyExpr2.Expr2Type = %Query_ExprConstant Then /* Expression is a constant */ &OldValue = &MyExpr2.Expr2Constant; /* do processing */ End-if;

The following is an example showing how to add a field for Expression 2:

( ) /* After setting the first expression, set the operator for the criteria*/ ​&MyCriteria.Operator = %Query_CondEqual; /* Set the type of the second expression to be a field */ ​&MyCriteria.Expr2Type = %Query_ExprField; /* Add the EMPLID field from the ABSENCE_HIST record whose record alias is A */ &MyField = &MyCriteria.AddExpr2Field("A", "EMPLID" );

Click to jump to top of pageClick to jump to parent topicLogical

Description

This property returns or sets the logical portion of a criteria.

Note. This property is valid only when there are more than one criteria for a query. Also, this property is required when there is more than one criteria for a query.

The values are:

Numeric Value

Constant Value

Description

1

%Query_CombAnd

Logical And for non-having criteria

2

%Query_CombOr

Or for non-having criteria

3

%Query_CombNotUsed

No logical operator. Used for the first non-having criteria.

4

%Query_CombHaveAnd

Logical And for having criteria

5

%Query_CombHaveOr

Logical Or for having Criteria

6

%Query_CombHaveNotUsed

No logical operator. Used for the first having criteria.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicLParenLvl

Description

This property returns or sets the left parenthesis level used for grouping criteria. This property takes a numeric value.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the Query Criteria, as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicNegation

Description

This property returns a Boolean value, indicating whether a criterion is negated: True if the criterion is negated, False if it isn't.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicOperator

Description

This property returns or sets the operator for the criteria.

The value of this property determines the valid types of the Expression 2, set with the Expr2Type property.

This property is read-write.

See Expr2Type, Working With Query Criteria and Expressions.

You can use either a constant or numeric value for this property. The values are:

Numeric Value

Constant Value

Description

1

%Query_CondNone

None (used for initializing a new criteria.)

2

%Query_CondEqual

Criteria's left-hand side is equal to right-hand side (= operator)

3

%Query_CondNotEqual

Criteria's left-hand side is not equal to right-hand side (<> operator)

4

%Query_CondGreaterThan

Criteria's left-hand side is greater than right-hand side (> operator)

5

%Query_CondNotGreaterThan

Criteria's left-hand side is not greater than right-hand side (<= operator)

6

%Query_CondLessThan

Criteria's left-hand side is less than right-hand side (< operator)

7

%Query_CondNotLessThan

Criteria's left-hand side is not less than right-hand side (>= operator)

8

%Query_CondInList

Criteria's left-hand side is in the given list (IN operator)

9

%Query_CondNotInList

Criteria's left-hand side is not in the given list (Not IN operator)

10

%Query_CondBetween

Criteria's left-hand side is between the two values of right-hand side (BETWEEN operator)

11

%Query_CondNotBetween

Criteria's left-hand side is not between the two values of right-hand side (BETWEEN operator)

12

%Query_CondExists

Criteria's left-hand side is the output of the subquery of right-hand side (EXISTS operator)

13

%Query_CondNotExists

Criteria's left-hand side doesn't exist in the output of the subquery of right-hand side (NOT EXISTS operator)

14

%Query_CondLike

Criteria's left-hand side is like (wildcard search) the right-hand side (LIKE operation)

15

%Query_CondNotLike

Criteria's left-hand side is not like (wildcard search) the right-hand side (NOT LIKE operation)

16

%Query_CondNull

Criteria's left-hand side is NULL (NULL operation)

17

%Query_CondNotNull

Criteria's left-hand side is not NULL (IS NOT NULL operation)

18

%Query_CondInTree

Criteria's left-hand side is from a list of nodes in Tree (IN operation)

19

%Query_CondNotInTree

Criteria's left-hand side is not from a list of nodes in Tree (NOT IN operation)

20

%Query_CondEffDtLessEqual

Criteria's left-hand side is an Effective Date and is less than or equal to the date on the right-hand side (<= operation)

21

%Query_CondEffDtGreaterEqual

Criteria's left-hand side is an Effective Date and is greater than or equal to the date on the right-hand side (>= operation)

22

%Query_CondEffDtLess

Criteria's left-hand side is an Effective Date and is less than the date on the right-hand side (< operation)

23

%Query_CondEffDtGreater

Criteria's left-hand side is an Effective Date and is greater than the date on the right-hand side (> operation)

24

%Query_CondFirstEffDt

Criteria's left-hand side is the first effective date (Function MIN())

25

%Query_CondLastEffDt

Criteria's left-hand side is the last effective date (Function MAX())

26

%Query_CondInTreeJoin

Criteria's left-hand side is an In Tree Join.

Click to jump to top of pageClick to jump to parent topicR1ExprNum

Description

This property returns or sets the expression number for the first expression of Expression 2. This property takes a numeric value.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicR2ExprNum

Description

This property returns or sets the expression number for the second expression of Expression 2. This property takes a numeric value.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicR1ExprType

Description

This property returns the expression type for the first expression of Expression 2. This property takes a numeric value and is the same range of values as the Expr2Type. It helps distinguish the type of an expression based on the value of Expr2Type. For instance, if the Expr2Type is Field-Expr, R1Expr2Type is of type Field and R2Expr2Type is of type Expression.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicR2ExprType

Description

This property returns the expression type for the second expression of Expression 2. This property takes a numeric value and is the same range of values as the Expr2Type. It helps distinguish the type of an expression based on the value of Expr2Type. For instance, if the Expr2Type is Field-Expr, R1Expr2Type is of type Field and R2Expr2Type is of type Expression.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicRParenLvl

Description

This property returns or sets the right parenthesis level used for grouping criteria. This property takes a numeric value.

This property is read-write.

Click to jump to parent topicQueryExpression Collection

A QueryExpression Collection is returned from the Expressions Query class property.

See QuerySelect class: Expressions property.

Click to jump to parent topicQueryExpression Collection Methods

In this section, we discuss the QueryExpression collection methods. The methods are described in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryExpression = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(ExpressionName)

Description

The ItemByName method returns the QueryExpression object in the QueryExpressionCollection with the given expression name.

Parameters

ExpressionName

The name of the required expression.

Returns

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

Example

&QryExpr = &QryExprCol.Item("Exp-6");

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryExpression object in the QueryExpression 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 QueryExpression object if successful, NULL otherwise.

Example

&MyQueryExpression = &MyCollection.Next();

Click to jump to parent topicQueryExpression Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryExpression objects in the QueryExpression Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryExpression Class

A QueryExpression object is returned by the following:

See AddExpression, QueryExpression Collection, QueryCriteria Class Methods, Expr1Expression, Expr2Expression1.

See Working With Query Criteria and Expressions.

Click to jump to parent topicQueryExpression Class Properties

In this section, we discuss the QueryExpression class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAggregate

Description

This property specifies whether the expression is an aggregate function.

This property takes a Boolean value: True if the expression is an aggregate function, False, otherwise.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicBindFlag

Description

This property specifies whether the expression contains a bind value, as Boolean value.

This property is mainly used while reading a query, to determine whether a Query Expression contains a bind value. It isn't necessary to set this value while saving a query to the database.

Values are:

Value

Description

False

Expression doesn't have a bind value

True

Expression has a bind value

This property is read-write.

Click to jump to top of pageClick to jump to parent topicDecimal

Description

This property returns or sets the decimal value of the expression.

This property is only valid with numeric fields.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicExpNum

Description

This property returns or sets the unique expression number, as a numeric value.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicIsXlatExpression

Description

This property indicates whether the expression is for a translate field. This property takes a Boolean value: True, the expression is based on a translated field.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLength

Description

This property returns or sets the length of the expression, as a number.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the expression, as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicOutputField

Description

This property returns the instance of the displayed expression field, as a QueryField. This property returns a NULL when the expression isn't used in a displayed (output) field.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicRightExprFlag

Description

This property specifies whether an expression is used in the right-hand side of a criteria (that is, is it an Expr2 expression), as a Boolean value.

This property is typically used while reading a query to determine whether a Query Expression is used in the right-hand side of criteria. It's not necessary to set this value while saving a query to the database.

Values are:

Value

Description

False

Expression is not used in the right-hand side of the criteria

True

Expression is used in the right-hand side of the criteria

This property is read-write.

Click to jump to top of pageClick to jump to parent topicSelectedField

Description

This property returns the instance of the expression field, as a QueryField. This property returns a NULL when the expression is used only in the right-hand side of a criteria.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicText

Description

This property returns or sets the text of the expression, as a character string.

This property is read-write.

Using ORACLE Hints in Expressions

Oracle hints can be included in expressions using the following considerations:

Click to jump to top of pageClick to jump to parent topicType

Description

This property returns or sets the field type of the expression.

You can specify either a constant or a numeric value. The values are:

Numeric Value

Constant Value

Description

0

%FieldType_Char

Character

1

%FieldType_LongChar

Long Character

2

%FieldType_Number

Number

3

%FieldType_SignedNumber

Signed number

4

%FieldType_Date

Date

5

%FieldType_Time

Time

6

%FieldType_DateTime

DateTime

7

%FieldType_Image

Image

11

%FieldType_URL

Drilling URL

This property is read-write.

Click to jump to parent topicQueryList Class

A QueryList Class is returned from the Expr2List property and AddExpr2List method of the QueryCriteria Class.

See QueryCriteria class: Expr2List property, AddExpr2List method.

Click to jump to parent topicQueryList Class Methods

In this section, we discuss the QueryList class methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAddListValue

Syntax

AddListValue(Value, IsPrompt)

Description

The AddListValue method adds a new List Value into the QueryList instance.

Parameters

Value

Specify the string value to be added to the list

IsPrompt

Specify whether the string specified by Value is a bind variable. This parameter takes a Boolean value: True, Value is a bind variable.

Returns

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

Example

&MyListValue = &MyList.AddListValue("1", False);

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

The First method returns the first QueryListValue object in the QueryList instance.

Parameters

None.

Returns

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

Example

&MyListValue = &MyList.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

The Item method returns the QueryListValue object that exists at the number position in the QueryList instance.

Parameters

Number

Specify the position number in the QueryList object that you want returned.

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryListValue object in the QueryList instance. This method should be called after calling First, else it returns NULL.

Parameters

None.

Returns

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

Example

&MyNextListValue = &MyList.Next();

Click to jump to parent topicQueryList Class Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryListValue objects in the QueryList Collection, as a number.

This property is read-only.

Example

&ListValueCount = &MYList.Count;

Click to jump to parent topicQueryListValue Class

A QueryListValue instance is returned from the AddListValue, First, Item, or Next QueryList Class methods.

See QueryList Class Methods.

Click to jump to parent topicQueryListValue Class Properties

In this section, we discuss the QueryListValue class properties. These properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicIsPrompt

Description

This property indicates whether the value is a bind variable (such as :1). This property returns a Boolean value: True, this property is a bind variable.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicValue

Description

This property returns a string for the value stored in the list.

This property is read-only.

Click to jump to parent topicQueryRecordHierarchy Collection

A QueryRecordHierarchy collection is returned from the RecordHierarchy QueryDBRecord property.

The order of each QueryRecordHierarchy object in the collection maps to the order of each tree node as it appears in the tree hierarchy from top to bottom.

See QueryDBRecord class: RecordHierachy property.

Click to jump to parent topicQueryRecordHierarchy Collection Methods

In this section, we discuss the QueryRecordHierarchy collection methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryRecordHierarchy = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(Name)

Description

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

Parameters

Name

Specify the name of an existing QueryRecordHierarchy within the QueryRecordHierarchy collection. If you specify an invalid name, the object is NULL.

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryRecordHierarchy object in the QueryRecordHierarchy 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 QueryRecordHierarchy object if successful, NULL otherwise.

Example

&MyQueryRecordHierarchy = &MyCollection.Next();

Click to jump to parent topicQueryRecordHierarchy Collection Property

In this section, we discuss the QueryRecordHierarchy properties. These properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryRecordHierarchy objects in the QueryRecordHierarchy Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryRecordHierarchy Class

A reference to a QueryRecordHierarchy object is returned by the First, Item, ItemByName, and Next QueryRecordHierarchy Collection methods.

Every QueryRecordHierarchy object returned from a collection represents a record node in the Record Hierarchy tree in Query tab of PeopleSoft Query.

The QueryRecordHierarchy object returned from the QueryField represents the prompt table for the record field.

See QueryRecordHierarchy Collection.

Click to jump to parent topicQueryRecordHierarchy Class Properties

In this section, we discuss the QueryRecordHierarchy class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicDescription

Description

This property returns a description of the record node as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLevel

Description

This property returns the level of the record node in the record hierarchy. 1 is the root node, 2 is a node beneath the root node, 3 is a child of that, and so on.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the record node as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicParentFlag

Description

This property returns the parent flag. The values are:

Value

Description

0

Record node contains no children nodes.

1

Record node contains children nodes

This property is read-only.

Click to jump to parent topicQuery Metadata Collection

A Query Metadata collection is returned by the Metadata Query class property.

See Query class: Metadata property.

See Using Query Metadata.

Click to jump to parent topicQuery Metadata Collection Methods

In this section, we discuss the Query Metadata collection methods. These methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyMetadata = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(Name)

Description

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

Parameters

Name

Specify the name of an existing Query Metadata within the Query Metadata collection. If you specify an invalid name, the object is NULL.

Returns

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

Example

&MyMetadata = &MyQuery.Metadata.ItemByName("Descr");

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next Query Metadata object in the Query Metadata 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 Metadata object if successful, NULL otherwise.

Example

&MyMetadata = &MyCollection.Next();

Click to jump to parent topicQuery Metadata Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of Query Metadata objects in the Query Metadata Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQuery Metadata Class

A Query Metadata object is returned from the Query Metadata Collection methods First, Item, ItemByName, or Next.

See Query Metadata Collection.

See Using Query Metadata.

Click to jump to parent topicQuery Metadata Class Properties

In this section, we discuss the Query Metadata class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of each Query Metadata property as a string.

Values for this property are:

Value

Description

Descr

Description

LongDescr

Long description

Public/Private

Specifies if the query is public or private. If the query is private, the name of the owner is listed in Value.

LastUpdDttm

Last updated date and time

LastUpdOprId

The UserId of the user who updated the value last

Record

Record name. May be more than one.

Input Param

Input parameter. May be more than one.

Expression

Expression. May be more than one.

Field

Record field name for the output column. May be more than one.

Heading

Heading name for the output column. May be more than one.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicValue

Description

This property returns the value for the Query Metadata property as a string.

This property is read-only.

Click to jump to parent topicQueryStatistics Class

The QueryStatistics class is used to view statistical information about a query's execution. It can be useful for query administration. You can view query statistics for a query before you save it to the database.

A QueryStatistics Class is returned from the QueryStatistics Query property.

See Query class: QueryStatistics property.

Click to jump to parent topicQueryStatistics Class Properties

In this section, we discuss the QueryStatistics properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAvgExecTime

Description

This property returns the average execution time for the query as a number.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicAvgFetchTime

Description

This property returns the average fetch time for the query as a number.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicAvgNumRows

Description

This property returns the average number of rows fetched for the query.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicExecCount

Description

This property returns the total number of times the query has been executed.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLastExecDtTm

Description

This property returns the last date and time the query was executed, as a string.

This property is read-only.

Click to jump to parent topicQuerySecurityProfile Class

The QuerySecurityProfile class is used to view the current user's security profile for PeopleSoft Query. This class doesn't contain any methods, and all the properties are read-only. An instance of this class is returned by the GetQuerySecurityProfile Session method.

See Session (query API) class: GetQuerySecurityProfile method.

Click to jump to parent topicQuerySecurityProfile Class Properties

In this section, we discuss the QuerySecurityProfile properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicAllowAnyJoin

Description

This property indicates whether the user is allowed to define queries with any join. This property takes a Boolean value: True, the user can define such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicAllowDistinct

Description

This property indicates whether the user can define queries with a Distinct clause in a SELECT statement. This property takes a Boolean value: True, the user can define such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicAllowExpressions

Description

This property indicates whether the user is allowed to define expressions in queries. This property takes a Boolean value: True, the user can define such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicAllowSubqueries

Description

This property indicates whether the user is allowed to define criteria containing subqueries. This property takes a Boolean value: True, the user can define such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicAllowUnions

Description

This property indicates whether the user is allowed to define queries containing unions. This property takes a Boolean value: True, the user can define such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicApprovePrivateQuery

Description

This property indicates whether the user is allowed to approve private queries. This property takes a Boolean value: True, the user can approve such queries. This property is meant for query administration.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicApprovePublicQuery

Description

This property indicates whether the user is allowed to approve public queries. This property takes a Boolean value: True, the user can approve such queries. This property is meant for query administration.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCanCreatePublic

Description

This property indicates whether the user can create public queries. This property takes a Boolean value: True, the user can create such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCanCreateWorkFlow

Description

This property indicates whether the user can create or run any workflow queries. Workflow queries are of the following types:

This property takes a Boolean value: True, the user can create such queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCanModifyQuery

Description

This property indicates whether the user can modify queries. This property takes a Boolean value: True, the user can modify queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCanRunQuery

Description

This property indicates whether the user can run queries. This property takes a Boolean value: True, the user can run queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCanRunToCrystal

Description

This property indicates whether the user can run queries to a Crystal report. This property takes a Boolean value: True, the user can run queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicCanRunToExcel

Description

This property indicates whether the user can run queries to an Excel spreadsheet. This property takes a Boolean value: True, the user can run queries.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLimitUnapproved

Description

This property indicates whether there is a limit on the number of rows returned for unapproved queries. This property is meant for query administration. This property takes a Boolean value: True, limit the number of rows. The MaxUnapprovedRows property is active only if this property is specified as True.

This property is read-only.

See Also

QuerySecurityProfile class: MaxUnapprovedRows property.

Click to jump to top of pageClick to jump to parent topicMaxInTreeCriteria

Description

This property indicates the maximum number of In Tree Criteria that can be used in the queries defined by the current user. This property takes a numeric value.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicMaxJoins

Description

This property indicates the maximum number of joins allowed in the queries defined by the current user. This property takes a numeric value.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicMaxRowsToFetch

Description

This property indicates the maximum number of rows to fetch for the current user when a query is executed. This property takes a numeric value.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicMaxUnapprovedRows

Description

This property indicates the maximum number of rows that can be returned for unapproved queries. This property takes a numeric value. This property is meant for query administration. This property is active only if the property LimitUnapproved is True.

This property is read-only.

See Also

QuerySecurityProfile class: LimitUnapproved property.

Click to jump to parent topicQueryDBRecord Collection

A QueryDBRecord collection is returned from the FindQueryDBRecords session method.

See Session (query API) class: FindQueryDBRecords method.

Click to jump to parent topicQueryDBRecord Collection Methods

In this section, we discuss the QueryDBRecord collection methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryDBRecord = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(Name)

Description

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

Parameters

Name

Specify the name of an existing QueryDBRecord within the QueryDBRecord collection. If you specify an invalid name, the object is NULL.

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryDBRecord object in the QueryDBRecord 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 QueryDBRecord object if successful, NULL otherwise.

Example

&MyQueryDBRecord = &MyCollection.Next();

Click to jump to parent topicQueryDBRecord Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryDBRecord objects in the QueryDBRecord Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryDBRecord Class

A QueryDBRecord object is returned from the QueryDBRecord Collection methods First, Item, ItemByName, or Next.

See QueryDBRecord Collection.

Click to jump to parent topicQueryDBRecord Class Methods

In this section, we discuss the QueryDBRecord class methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicQueryDBRecordFieldByIndex

Syntax

QueryDBRecordFieldByIndex(Index)

Description

The QueryDBRecordFieldByIndex method returns the QueryDBRecordField object that exists at the index position in the QueryDBRecordField collection.

Parameters

Index

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

Returns

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

See Also

QueryDBRecordFieldByName, QueryDBRecordField Class.

Click to jump to top of pageClick to jump to parent topicQueryDBRecordFieldByName

Syntax

QueryDBRecordFieldByName(Name)

Description

The QueryDBRecordFieldByName method returns the QueryDBRecordField object with the name Name.

Parameters

Name

Specify the name of the QueryDBRecordField object that you want returned.

Returns

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

See Also

QueryDBRecordFieldByIndex, QueryDBRecordField Class.

Click to jump to parent topicQueryDBRecord Class Properties

In this section, we discuss the QueryDBRecord class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicDescription

Description

This property returns the description of the QueryDBRecord as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the QueryDBRecord as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicQueryDBRecordFields

Description

This property returns a reference to a QueryDBRecordField Collection.

This property is read-only.

See Also

QueryDBRecordField Collection.

Click to jump to top of pageClick to jump to parent topicRecordHierachy

Description

This property returns a reference to a QueryRecordHierarchy Collection.

The record hierarchy is not related to the query tree hierarchy shown when viewing access groups. Instead, it reflects an actual relationship between the record components, as defined in Application Designer using the Parent Record Name feature.

This property is read-only.

See Also

QueryRecordHierarchy Collection.

PeopleSoft Query Security

Click to jump to parent topicQueryDBRecordField Collection

A QueryDBRecordField collection is returned from the QueryDBRecordFields QueryDBRecord property.

See QueryDBRecord class: QueryDBRecordFields property.

Click to jump to parent topicQueryDBRecordField Collection Methods

In this section, we discuss the QueryDBRecordField collection methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryDBRecordField = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(Name)

Description

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

Parameters

Name

Specify the name of an existing QueryDBRecordField within the QueryDBRecordField collection. If you specify an invalid name, the object is NULL.

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryDBRecordField object in the QueryDBRecordField 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 QueryDBRecordField object if successful, NULL otherwise.

Example

&MyQueryDBRecordField = &MyCollection.Next();

Click to jump to top of pageClick to jump to parent topicSort

Syntax

Sort(SortCriteria)

Description

Use the Sort method to sort the fields within the QueryDBRecordField collection, based on the sort criteria specified with the method.

Parameters

SortCriteria

Specify the sort order for the list. This parameter can take either a constant or numeric value. See below.

The values for OutputFormat can be as follows:

Numeric Value

Constant Value

Description

1

%Query_SortNameAsc

Sort database fields in ascending order based on field name.

2

%Query_SortNameDesc

Sort database fields in descending order based on field name.

3

%Query_SoftFldNumAsc

Sort database fields in ascending order based on field number.

4

%Query_SortFldNumDesc

Sort database fields in descending order based on field number.

Returns

0

Click to jump to parent topicQueryDBRecordField Collection Property

In this section, we discuss the Count property.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryDBRecordField objects in the QueryDBRecordField Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryDBRecordField Class

A QueryDBRecordField object is from the QueryDBRecord Collection methods First, Item, ItemByName or Next.

See QueryDBRecord Collection.

Click to jump to parent topicQueryDBRecordField Class Method

In this section, we discuss the QueryDBRecordField class methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicGetImageFormat

Syntax

GetImageFormat()

Description

Use the GetImageFormat method to differentiate between images and files, both stored as BLOBs in the database.

Note. Because images and files share the field type value 8, this method is required to differentiate between the two types.

Parameters

None.

Returns

A number. A value 16 indicates that the field is of type file (or attachment).

See Also

Type

Click to jump to parent topicQueryDBRecordField Class Properties

In this section, we discuss the QueryDBRecordField class properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicDecimal

Description

This property returns the decimal positions for a field. This indicates how many numbers are allowed on the right side of the decimal.

This property is read-only.

Example

&FldDecs = &QryDBRcdFlds.Decimal;

Click to jump to top of pageClick to jump to parent topicDescription

Description

This property returns the long description of the field as a string.

This is property is read-only.

Click to jump to top of pageClick to jump to parent topicFlag

Description

This property returns the Use and Edit Flags of the field, which are set when the Field is defined in Application Designer, as a numeric value.

Values for Use Flags are:

Value

Description

1

Key

2

Duplicate Key

4

System

8

Audit Field Add

16

Alternate Key

32

List Item

64

Descending Key

128

Audit Field Change

1024

Audit Field Delete

2048

Search Item

32768

Auto Update

Values for Edit Flags are:

Value

Description

256

Required

512

Edit Translate

4096

Date Range Edit

8192

Yes/No Table Edit

16384

Edit Table

262144

From Search Field

524288

Through Search Field

8388608

Use Default Label Flag

16777216

Default Search Field

This is a read-only property.

Click to jump to top of pageClick to jump to parent topicFormat

Description

This property returns the field format for a field. Values are:

Value

Description

1

No format

2

Name

3

Phone Number North America

4

Zip/Postal Code North America

5

Social Security Number (SSN)

6

Uppercase

7

Mixed case

8

Raw binary

9

Numbers only

10

Canadian Social Insurance Number (SIN)

11

Phone Number International

12

Zip/Postal Code International

13

Seconds

14

Microseconds

15

Custom

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLength

Description

This property returns the length of the field as a number.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLongName

Description

This property returns the long name of the field as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicLookupTableName

Description

If the field has a lookup table associated with it, this property returns the name of that Lookup Table, else it returns an empty string.

This is a read-only property.

Click to jump to top of pageClick to jump to parent topicLookupTableRecord

Description

If the field has a lookup table associated with it, this property returns the instance of the QueryDBRecord for that Lookup Table, else it returns NULL.

This is a read-only property.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the field as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicShortname

Description

This property returns the short name of the field as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicType

Description

This property returns the type of the field. You can specify either a constant or a numeric value for this property. The values are:

Numeric Value

Constant Value

Description

0

%FieldType_Char

Character

1

%FieldType_LongChar

Long Character

2

%FieldType_Number

Number

3

%FieldType_SignedNumber

Signed number

4

%FieldType_Date

Date

5

%FieldType_Time

Time

6

%FieldType_DateTime

Datetime

8

%FieldType_Image

Image

8

%FieldType_File

File

9

%FieldType_ImageRef

ImageReference

Note. The Image and File types can be differentiated using the GetImageFormat method of the QueryField class.

This property is read-only.

See Also

GetImageFormat

Click to jump to parent topicQueryPrompt Collection

A QueryPrompt collection is returned from the Prompts and RuntimePrompts Query class properties.

See Query class: Prompts property, RunTimePrompts property.

Click to jump to parent topicQueryPrompt Collection Methods

In this section, we discuss the QueryPrompt collection methods. The methods are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicFirst

Syntax

First()

Description

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

Parameters

None.

Returns

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

Example

&MyQueryPrompt = &MyCollection.First();

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

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

Parameters

Number

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

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(Name)

Description

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

Parameters

Name

Specify the name of an existing QueryPrompt within the QueryPrompt collection. If you specify an invalid name, the object is NULL.

Returns

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

Example

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

Click to jump to top of pageClick to jump to parent topicNext

Syntax

Next()

Description

The Next method returns the next QueryPrompt object in the QueryPrompt 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 QueryPrompt object if successful, NULL otherwise.

Example

&MyQueryPrompt = &MyCollection.Next();

Click to jump to parent topicQueryPrompt Collection Property

In this section, we discuss the QueryPrompt collection properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of QueryPrompt objects in the QueryPrompt Collection, as a number.

This property is read-only.

Example

&COUNT = &MY_COLLECTION.Count;

Click to jump to parent topicQueryPrompt Class

A reference to a QueryPrompt is returned by the following:

See QueryPrompt Collection, AddPrompt.

See Defining Prompts.

Click to jump to parent topicQueryPrompt Properties

In this section, we discuss the QueryPrompt properties. The properties are discussed in alphabetical order.

Click to jump to top of pageClick to jump to parent topicEditType

Description

This property returns or sets the edit type for the field. This property takes a number value. The values are:

Value

Description

0

No table edit

16384

Prompt table

512

Translate table

8192

Yes/No

This property is read-write.

Click to jump to top of pageClick to jump to parent topicFieldDecimal

Description

This property returns or sets the decimal value for the field.

This property is only valid with number fields.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicFieldFormat

Description

This property returns the field format for a field. This property takes a number value. Values are:

Value

Description

0

None

1

Name

2

Phone

3

Zip Code

4

Social Security Number

5

Upper

6

Mixed Case

7

Century

8

Number Only

9

Social Insurance Number

10

International Phone Number

11

International Postal Code

12

Seconds

13

Microseconds

14

Century/Seconds

15

Century/Microseconds

This property is read-only.

Click to jump to top of pageClick to jump to parent topicFieldLength

Description

This property returns or sets the field length.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicFieldName

Description

This property returns or sets the field name used with the prompt.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicFieldType

Description

This property returns or sets the field type of the field used with the prompt.

This property returns the type of the field. You can specify either a constant or a numeric value. The values are:

Numeric Value

Constant Value

Description

0

%FieldType_Char

Character

1

%FieldType_LongChar

Long Character

2

%FieldType_Number

Number

3

%FieldType_SignedNumber

Signed number

4

%FieldType_Date

Date

5

%FieldType_Time

Time

6

%FieldType_DateTime

Datetime

7

%FieldType_Image

Image

This property is read-write.

Click to jump to top of pageClick to jump to parent topicHeadingText

Description

This property returns or sets the heading text for the prompt field.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicHeadingType

Description

This property returns or sets the heading type for the query field. This property takes either a constant or numeric value. The values are:

Numeric Value

Constant Value

Description

1

%Query_HdgNone

Query field has no heading.

2

%Query_HdgText

Query field has a text heading.

3

%Query_HdgRftShort

Query field uses the short RFT heading.

4

%Query_HdgRftLong

Query fields uses the long RFT heading.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicLangCount

Description

This property returns the total count of the language records for the current prompt.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns a string containing the Prompt name. When an existing query is read, this name is the same as the Field Name. When a new prompt is added using AddPrompt, this is the Name parameter used with that method.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicPromptRecordFieldName

Description

When you have more than one field with the same name in the prompt collection, the system generates a unique prompt field name for each repeated field. The generated names are of the form Bind1, Bind2, and so on. This property returns the unique name for the prompt record field.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicPromptTable

Description

This property returns or sets the prompt table name for the prompt field.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicUniquePromptName

Description

This property returns or sets the unique prompt name for the prompt field.

This property is read-write.

Click to jump to top of pageClick to jump to parent topicUseCount

Description

This property returns the total count of the usage of the current prompt.

This property is read-only.

The following are examples of the usual actions that you perform using the query classes.

Click to jump to parent topicQuery Classes Examples

The following are examples of the usual actions that you perform using the query classes.

Click to jump to top of pageClick to jump to parent topicCreating a New Query

In this example, you are creating a new query, adding a record and two fields. The following is the complete code sample: the steps explain each line.

Local ApiObject &aQuery, &aQrySelCol; Local ApiObject &COLL, &ERROR; Local String &TEXT; Local Session &MySession; Local Record &aQryRcd; Local Field &aQryFld; &MySession = %Session; If &MySession <> Null Then &aQuery = &MySession.GetQuery(); &aQuery.Create("TEST1", False, %Query_Query, "PIA Test 1", ⇒ "Creating Test Query 1 from PIA Page"); &aQrySel = &aQuery.AddQuerySelect(); &aQryRcd = &aQrySel.AddQueryRecord("ABSENCE_HIST"); &aQryFld = &aQrySel.AddQuerySelectedField("ABSENCE_HIST", "A", "EMPLID", "ID"); If &aQryFld <> Null Then &aQryFld.ColumnNumber = 1; &aQryFld.HeadingType = %Query_HdgRftShort; End-If; &Rslt = &aQuery.Save(); If &Rslt <> 0 Then /* save didn't complete */ &COLL = &MySession.PSMessages; For &I = 1 to &COLL.Count &ERROR = &COLL.Item(&I); &TEXT = &ERROR.Text; /* do error processing */ End-For; &COLL.DeleteAll(); End-if; /* error processing for not getting a session */ End-if;

To create a new query:

  1. Get a session object.

    Before you can create a query, you have to get a session object. The session controls access to the query, provides error tracing, enables you to set the runtime environment, and so on. Then this program checks to verify that the session object is valid.

    &MySession = %Session; &aQuery = &MySession.GetQuery(); If &MySession <> Null Then

  2. Create the query.

    Use the Create method to create the query. This query is a private query, of type query.

    &aQuery.Create("TEST1", False, %Query_Query, "Test 1", "Creating Test Query");

  3. Add a QuerySelect.

    The QuerySelect contains the main query statement for the query. There can be multiple QuerySelect objects for queries that involve unions or subqueries. Each select (or union or subquery) consists of QueryRecords, QueryOutputFields, QuerySelectedFields, and QueryCriteria and is treated as a child of the MAIN select statement.

    &aQrySel = &aQuery.AddQuerySelect();

  4. Add a record and a field.

    The AddQueryRecord method adds a query record to the query. The AddQuerySelectedField adds a field, using the record alias "A". The ID is what gets displayed in the heading for the query.

    &aQryRcd = &aQrySel.AddQueryRecord("ABSENCE_HIST"); &aQryFld = &aQrySel.AddQuerySelectedField("ABSENCE_HIST", "A", "EMPLID", "ID");

  5. Make the field an output field.

    The field was added as a selected field. By setting the ColumnNumber to a number greater than one, the field is now an output field. The text that's displayed in the heading comes from the RFT short description of the field.

    If &aQryFld <> Null Then &aQryFld.ColumnNumber = 1; &aQryFld.HeadingType = %Query_HdgRftShort; End-If;

  6. Save the data.

    When you execute the Save method, the new query is saved to the database.

    &Rslt = &aQuery.Save(); If &Rslt <> 0 Then

    The Save method returns a numeric value: 0 if successful. You can use this value to do error checking.

  7. Check Errors.

    You can check if there were any errors using the PSMessages property on the session object.

    /* save didn't complete */ &COLL = &MySession.PSMessages; For &I = 1 to &COLL.Count &ERROR = &COLL.Item(&I); &TEXT = &ERROR.Text; /* do error processing */ End-For; &COLL.DeleteAll(); End-if;

    If there are multiple errors, all errors are logged to the PSMessages collection, not just the first occurrence of an error. As you correct each error, you may want to delete it from the PSMessages collection.

Click to jump to top of pageClick to jump to parent topicAdding Criteria

In this example, you are accessing an existing query, then adding criteria both as part of the query as well as part of a subquery. The SQL statement created by this subquery is as follows:

SELECT RECNAME, RECDESCR, RELLANGRECNAME, PARENTRECNAME, DESCRLONG from PSRECDEFN ⇒ ​where RECNAME IN ​(select OBJECTVALUE1 from PSPROJECTITEM where PROJECTNAME =⇒ 'PPLTOOLS') AND RECTYPE = 0 ​order by RECNAME

The following is the complete code sample: the steps explain each line.

Local ApiObject &MyQuery, &MainQrySel, &Criteria1, &MyCrit2Expr2, &MyCriteria2; Local ApiObject &SubQrySel, &SubQryCrit1, &SubQryExpr1, &MyCrit2Expr2; Local Record &SubQryRec; Local Session = &MySession; Local ApiObject &COLL, &ERROR; Local String &TEXT; &MySession = %Session; If &MySession <> Null Then &MyQuery = &MySession.GetQuery(); &MyQuery.Open("Table", False, True); &MainQrySel = &MyQuery.QuerySelect; /* Add query record, add fields, then make selected fields output fields */ &MainRec = &MainQrySel.AddQueryRecord("PSRECDEFN"); &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "RECNAME", "Record Name"); &QryFld.ColumnNumber = 1; &QryFld.OrderByNumber = 1; &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "RECDESCR", "Record Descr"); &QryFld.ColumnNumber = 2; &QryFld.OrderByNumber = 2; &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "RELLANGRECNAME", "Record Lang Rec"); &QryFld.ColumnNumber = 3; &QryFld.OrderByNumber = 3; &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "PARENTRECNAME", "Parent Record Name"); &QryFld.ColumnNumber = 4; &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "DESCRLONG", "Long Descr"); &QryFld.ColumnNumber = 5; &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "EMPLID", "ID"); &QryFld.ColumnNumber = 6; /* adding first criteria */ &Criteria1 = &MainQrySel.AddCriteria("FirstCriteria"); /* First criteria will not have any logical AND/OR */ &Criteria1.Logical = %Query_CombNotUsed; &Criteria1.Expr1Type = %Query_ExprField; &Criteria1.AddExpr1Field(&MainRec.RecordAlias, "RECNAME"); /* So that the criteria is constructed as - RECNAME IN (...)*/ &Criteria1.Operator = %Query_CondInList; &Criteria1.Expr2Type = %Query_ExprSubQuery; &SubQrySel = &Criteria1.AddExpr2SubQuery(); &SubQryRec = AddQueryRecord("PSPROJECTITEM"); &SubQryFld1 = &SubQrySel.AddQuerySelectedField(&SubQryRec.Name, &SubQryRec.Record⇒ Alias, "OBJECTVALUE1", "Join Object") &SubQryFld1.ColumnNumber = 1; /* Need criteria - PROJECTNAME = 'PPLTOOLS' - in the subquery */ &SubQryCrit1 = &SubQrySel.AddCriteria("FirstSubCrit"); /* First criteria will not have any logical AND/OR */ &SubQryCrit1.Logical = %Query_CombNotUsed; &SubQryCrit1.Expr1Type = %Query_ExprField; &SubQryCrit1.AddExpr1Field(&SubQryRec.RecordAlias, "PROJECTNAME"); &SubQryCrit1.Operator = %Query_CondEqual; /* So that the criteria is constructed as - PROJECTNAME = 'PPLTOOLS'*/ &SubQryCrit1.Expr2Type = %Query_ExprConstant; &SubQryExpr1 = &SubQryCrit1.AddExpr2Expression(); &SubQryExpr1.Text = "PPLTOOLS"; &SubQryCrit1.Expr2Expression1 = &SubQryExpr1; /* Second Criteria, which is for RECTYPE = 0 */ &MyCriteria2 = &MainQrySel.AddCriteria("SecondCriteria"); &MyCriteria2.Expr1Type = %Query_ExprField; &MyCriteria2.AddExpr1Field(&MainRec.RecordAlias, "RECTYPE"); /* Since this is second criteria, we need a logical AND to state that */ /* - AND RECTYPE = 0 */ &MyCriteria2.Logical = %Query_CombAnd; &MyCriteria2.Operator = %Query_CondEqual; &MyCriteria2.Expr2Type = %Query_ExprConstant; &MyCrit2Expr2 = &MyCriteria2.AddExpr2Expression(); &MyCriteria2.Expr2Expression1 = &MyCrit2Expr2; &MyCrit2Expr2.Text = "0"; &Rslt = &MyQuery.Save(); If &Rslt <> 0 Then /* save didn't complete */ &COLL = &MySession.PSMessages; For &I = 1 to &COLL.Count &ERROR = &COLL.Item(&I); &TEXT = &ERROR.Text; /* do error processing */ End-For; &COLL.DeleteAll(); End-if; Else /* do error processing for not getting session */ End-if;

To add criteria to a query:

  1. Get a session object.

    Before you can create a query, you have to get a session object. The session controls access to the query, provides error tracing, enables you to set the runtime environment, and so on. Then this program checks to verify that the session object is valid.

    &MySession = %Session; &MyQuery = &MySession.GetQuery(); If &MySession <> Null Then

  2. Access an existing query and get the main query select statement.

    Use the Open method to get the existing query. Then access the main select statement with the QuerySelect property.

    &MyQuery.Open("Table", False, True); &MainQrySel = &MyQuery.QuerySelect;

  3. Add Query Record in the Main Select.

    Add the query record that you want to use.

    &MainRec = &MainQrySel.AddQueryRecord("PSRECDEFN");

  4. Add the displayed fields.

    You want to add the selected fields. Note instead of hardcoding the name of the record, this code example uses the Name property. Also, the code uses the RecordAlias property instead of hardcoding the alias. This makes the code easier to read, as well as easier to maintain. Specifying a column number also makes this an output field.

    &QryFld = &MainQrySel.AddQuerySelectedField(&MainRec.Name, &MainRec.RecordAlias,⇒ "RECNAME", "Record Name"); &QryFld.ColumnNumber = 1;

  5. Specify the OrderBy value.

    Because we need to order by this field, the OrderByNumber of that field must be set also.

    &QryFld.OrderByNumber = 1;

  6. Add the first criteria.

    Add the first criteria. You don't want it added with any kind of operator, like an AND or an OR, so the Logical property of the first criteria is set with %Query_CombNotUsed. This is also used because it's the first non-having criteria of a query.

    /* adding first criteria */ &Criteria1 = &MainQrySel.AddCriteria("FirstCriteria"); /* First criteria will not have any logical AND/OR */ &Criteria1.Logical = %Query_CombNotUsed;

  7. Add the first criteria field.

    The first field for the criteria is a QueryExpression type field. The type of the field must be set before the field is added.

    &Criteria1.Expr1Type = %Query_ExprField; &Criteria1.AddExpr1Field(&MainRec.RecordAlias, "RECNAME");

  8. Add the condition for the first criteria and the subquery.

    The first criteria is the WHERE RECNAME IN portion of the SQL statement. The condition is considered 'in list', where the list is the result of the subquery. The expression is a subquery. Again, you have to set the type again before adding the subquery.

    &Criteria1.Operator = %Query_CondInList; &Criteria1.Expr2Type = %Query_ExprSubQuery; &SubQrySel = &Criteria1.AddExpr2SubQuery();

  9. Add the records for the subquery.

    Add the query record and the field from the query field, and make it an output field.

    &SubQryRec = AddQueryRecord("PSPROJECTITEM"); &SubQryFld1 = &SubQrySel.AddQuerySelectedField(&SubQryRecName.Name, ⇒ &SubQryRec.RecordAlias, "OBJECTVALUE1", "Join Object"); &SubQryFld1.ColumnNumber = 1;

  10. Add the criteria in the subquery.

    The following code adds the criteria for the subquery. Because this is the first non-having criteria in a select statement, the Logical property is set as %Query_CombNotUsed. Then the first expression is added as a field, and set to be equal to the second expression, PPLTOOLS. This is the where PROJECTNAME = 'PPLTOOLS' portion of the SQL statement.

    /* Need criteria - PROJECTNAME = 'PPLTOOLS' - in the subquery */ &SubQryCrit1 = &SubQrySel.AddCriteria("FirstSubQryCrit"); /* First criteria will not have any logical AND/OR */ &SubQryCrit1.Logical = %Query_CombNotUsed; &SubQryCrit1.Expr1Type = %Query_ExprField; &SubQryCrit1.AddExpr1Field(&SubQryRec.RecordAlias, "PROJECTNAME"); &SubQryCrit1.Operator = %Query_CondEqual; /* So that the criteria is constructed as - PROJECTNAME = 'PPLTOOLS'*/ &SubQryCrit1.Expr2Type = %Query_ExprConstant; &SubQryExpr1 = &SubQryCrit1.AddExpr2Expression(); &SubQryExpr1.Text = "PPLTOOLS"; &SubQryCrit1.Expr2Expression1 = &SubQryExpr1;

  11. Add the second criteria to the main select.

    Add the second criteria. Remember to set the type for the expression field first. Because this is the second criteria, we need a logical AND to state that this criteria is used with the first criteria.

    /* Second Criteria, which is for RECTYPE = 0 */ &MyCriteria2 = &MainQrySel.AddCriteria("SecondCriteria"); &MyCriteria2.Expr1Type = %Query_ExprField; &MyCriteria2.AddExpr1Field(&MainRec.RecordAlias, "RECTYPE"); /* Since this is second criteria, we need a logical AND to state that*/ /* - AND RECTYPE = 0 */ &MyCriteria2.Logical = %Query_CombAnd; &MyCriteria2.Operator = %Query_CondEqual; &MyCriteria2.Expr2Type = %Query_ExprConstant; &MyCrit2Expr2 = &MyCriteria2.AddExpr2Expression(); &MyCriteria2.Expr2Expression1 = &MyCrit2Expr2; &MyCrit2Expr2.Text = "0";

  12. Save the data.

    When you execute the Save method, the new query is saved to the database.

    &Rslt = &MyQuery.Save(); If &Rslt <> 0 Then

    The Save method returns a numeric value: 0 if successful. You can use this value to do error checking.

  13. Check Errors

    You can check if there were any errors using the PSMessages property on the session object.

    /* save didn't complete */ &COLL = &MySession.PSMessages; For &I = 1 to &COLL.Count &ERROR = &COLL.Item(&I); &TEXT = &ERROR.Text; /* do error processing */ End-For; &COLL.DeleteAll(); End-if;

    If there are multiple errors, all errors are logged to the PSMessages collection, not just the first occurrence of an error. As you correct each error, you may want to delete it from the PSMessages collection.

Click to jump to top of pageClick to jump to parent topicUsing Outer Joins

The following PeopleCode query uses outer joins:

Local ApiObject &aQuery, &aQrySelCol; Local ApiObject &aQryRcd, &aQryRcd2; Local ApiObject &aQryFld, &aQryFld2; Local ApiObject &aQrySel, &Criteria1; Local number &Rslt; &aQuery = %Session.GetQuery(); &aQuery.Create("TEST1", False, %Query_Query, "PIA Test 1", ⇒ "Creating Test Query1 from PIA Page"); &aQrySel = &aQuery.AddQuerySelect(); &aQryRcd = &aQrySel.AddQueryRecord("JOB"); &aQryRcd.RecordAlias = "A"; &aQryRcd2 = &aQrySel.AddQueryRecord("PERSONAL_DATA"); &aQryRcd2.RecordAlias = "B"; &aQryRcd2.JoinType = %Query_JoinLeftOuter; &aQryRcd2.JoinAlias = "A"; &aQryFld = &aQrySel.AddQuerySelectedField("JOB", "A", "EMPLID", "EMPLID"); &aQryFld.ColumnNumber = 1; &aQryFld.HeadingType = %Query_HdgRftShort; &aQryFld2 = &aQrySel.AddQuerySelectedField("PERSONAL_DATA", "B", ⇒ "NAME", "NAME"); &aQryFld2.ColumnNumber = 2; &aQryFld.HeadingType = %Query_HdgRftShort; &Criteria1 = &aQrySel.AddCriteria("JoinCriteria"); &Criteria1.Logical = %Query_CombNotUsed; &Criteria1.Expr1Type = %Query_ExprField; &Criteria1.AddExpr1Field("A", "EMPLID"); &Criteria1.Operator = %Query_CondEqual; &Criteria1.Expr2Type = %Query_ExprField; &Criteria1.AddExpr2Field1("B", "EMPLID"); &Criteria1.OJAlias = "B"; &Rslt = &aQuery.Save();

The above PeopleCode program produces the following SQL:

SELECT A.EMPLID, B.NAME FROM (PS_JOB A LEFT OUTER JOIN PS_PERSONAL_DATA B ON A.EMPLID=B.EMPLID)