The QuerySelect class represents the select statement of the SQL used in the query definition. This can be any of the following:
The main select statement.
The select statement in each union.
The select statement in each subquery.
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:
The QuerySelect collection methods AddUnion, First, Item, ItemBySelNum, or Next
The QuerySelect Query property