This chapter provides an overview of Query classes and discusses each class in detail.
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
Getting Started with PeopleSoft Query
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:
QuerySelect collection
QueryDBRecord collection
QueryDBRecordField collection
Query Collection
QueryRecord collection
QueryOutputField collection
QuerySelectedField collection
QueryCriteria collection
QueryExpression collection
QueryPrompt collection
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.
Invoke the GetQuery method on the PeopleSoft session object to get a query.
Either open the specific query you want using Open, or create a new query using Create.
Read the query statistics, or make changes as appropriate, adding records, field, criteria, and so on.
(Optional) Use the RunToRowset method to run the query. You can also use the RunToFile method to execute a scheduled query.
Note. Be careful whenever you write a PeopleCode program that uses the RunToRowset method because this method could potentially 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.
Save the changes.
Close the query.
If you want, you can navigate to PeopleSoft Query Manager, Query Viewer or the Query Designer to run the query.
Life cycle of Query object
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)
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. |
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.
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. |
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.
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.
All the fields that make up the query definition. These include the fields selected as output fields, and fields added as QueryExpressions.
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 Criteria and Expressions
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.
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 rows of 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 only in the Query API.
See Also
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";
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.
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 |
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
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
There are two ways of accessing information about a query:
The Query classes (QueryOutputField, QueryRecord, and so on).
The Metadata property.
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
With Query API, you have the following options for running a query:
Use the RunToRowset method
This method takes a Query Prompt Record as input and returns a PeopleCode rowset containing the query result. You should always use a standalone rowset (that is, one that was created using CreateRowset).
Use the RunToFile method
This method takes a Query Prompt Record and a file name as input and writes the query result to the file.
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 getting large result sets, of the order of 50000 or more.
Both 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 both RunToRowset and RunToFile is the maximum number of rows to fetch.
-1 returns all rows regardless of the setting on the security profile.
0 returns the maximum number of rows allowed by the security profile.
>0 is the limit on the number of rows.
See RunToFile.
See RunToRowset.
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.
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
Understanding PeopleSoft Security
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:
Save, RunToRowset, or RunToFile Query class methods.
SQL, RuntimePrompts, or Prompts Query class properties.
Any of the methods or properties in the QueryPrompts collection.
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
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.
You can have Where (simple) criteria or Having criteria in a query. In most cases, you only have a WHERE clause, 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:
Having criteria are accessed using either the AddHavingCriteria QuerySelect method or HavingCriteria QuerySelect property
Simple criteria are accessed using either the AddCriteria QuerySelect method or the Criteria QuerySelect property.
However, the Having criteria and the simple criteria have all the same methods and properties, so in this documentation, they're described together under the heading QueryCriteria.
See Also
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;
All query objects can be instantiated from PeopleCode only.
You can use this object anywhere you have PeopleCode, that is, in message subscription PeopleCode, 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;
The following methods are part of the Query API. However, they're used with a Session object.
See Also
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. Valid values are: |
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. |
OwnerType |
Specify the type of owner, whether the query is public or private. |
CaseSensitive |
This parameter has not yet been implimented. |
Returns
A reference to a Query collection containing zero or more queries.
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 UserID (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.
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 UserID (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.
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.
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.
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 class: FindQueries method, FindQueriesDateRange method, Open method, Create method.
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
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 UserID (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. Values are: |
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. |
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. |
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 class: FindQueryDBRecords method.
Syntax
SearchPrivateQueries(QueryType, 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, 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. Values are: |
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. |
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. Values are: |
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. |
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. |
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, %Query_FindName, "A%", False);
See Also
Session class: FindQueries method, FindQueriesDateRange method, SearchPublicQueries method.
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. Values are: |
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 |
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. Values are: |
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. |
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. |
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 class: FindQueries method, FindQueriesDateRange method, SearchPrivateQueries method.
A query collection is returned from the following session methods:
FindQueries
FindQueriesDateRange
SearchPrivateQueries
SearchPublicQueries
See Also
In this section, we discuss each query collection method.
Syntax
First()
Description
The First method returns the first Query object in the Query collection.
Parameters
None.
Returns
A reference to a Query object if successful, NULL otherwise.
Example
&MyQuery = &MyCollection.First();
Syntax
Item(number)
Description
The Item method returns the Query object that exists at the number position in the Query collection.
Item Considerations
FindQueries and FindQueriesDateRange return both public and private queries. It depends on your database whether the private query is returned first or the public query. If you have two queries with the same name, it depends on your database whether the first use of Item returns the private or the public query.
Parameters
Number |
Specify the position number in the collection of the Query object that you want returned. |
Returns
A reference to a Query object if successful, NULL otherwise.
Example
For &I = 1 to &QueryColl.Count; &MyQuery = &QueryColl.Item(&I); /* do processing */ End-For;
Syntax
ItemByName(Name)
Description
The ItemByName method returns the Query object with the name Name.
Parameters
Name |
Specify the name of an existing Query within the Query collection. If you specify an invalid name, the object is NULL. The length of this parameter is 30 characters. |
Returns
A reference to a Query object if successful, NULL otherwise.
Example
&MyQuery = &MyCollection.ItemByName("PHONELIST");
Syntax
Next()
Description
The Next method returns the next Query object in the Query collection. You can use this method only after you have used the First method: otherwise the system doesn’t know where to start.
Parameters
None.
Returns
A reference to a Query object if successful, NULL otherwise.
Example
&MyQuery = &MyCollection.Next();
In this section, we discuss the Count query collection property.
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;
A query object is returned from the following:
The GetQuery session method.
The Query Collection methods First, Item, ItemByName, or Next.
See Session class: GetQuery method.
See Query Collection.
In this section, we discuss each Query class method.
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
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 .
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.
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. Values are: |
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 |
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. |
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
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.
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 .
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 .
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, 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. The values are: |
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. |
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. |
Returns
A string containing the formatted output.
Example
/* you want to use RowCount, not ActiveRowCount, to get the total number of rows. */
&End = &MyRowset.RowCount; &FormString = &MyQuery.(&MyRowset, %Query_TXT, 1, &End);
See Also
Query class: RunToFile method, RunToRowset method.
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:
Query (User)
View
Role
Process
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
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.
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. The values are: |
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. |
MaxRows |
Specify the maximum number of rows to be fetched. This parameter takes a numeric value. The values are:
|
Returns
Returns 0 if successful.
Example
To run a query using the Query API RunToFile method:
Open the query.
&aRunQry = %Session.GetQuery(); &aRunQry.Open(&sQryName, False, False);
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);
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);
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.
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:
|
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:
Open the Query.
&aRunQry = %Session.GetQuery(); &aRunQry.Open(&sQryName, False, False);
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);
Run the query.
Now that you have the prompt values, you can run the query:
&aRowSet = &aRunQry.RunToRowset(&aQryPromptRec, 0);
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> </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.
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.
In the following section, we discuss each Query class property.
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.
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 UserID 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.
Description
This property returns a string containing the UserID of the user who approved the query. This can be useful for query administration.
This property is read-write.
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.
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.
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.
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.
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.
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.
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.
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.
Description
This property is used to group queries together. This parameter takes a string value, up to 18 characters.
This property is read-write.
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.
Description
This property returns the most recent date-time when the query was updated as a string.
This property is read-only.
Description
This property returns the User Id of the user who updated the query most recently as a string.
This property is read-only.
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.
Description
This property returns a metadata collection.
This property is read-only.
Example
&MetadataList = &MyQuery.Metadata;
See Also
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.
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.
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 |
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.
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.
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.
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;
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
Description
This property returns statistical information pertaining to the query’s execution as a QueryStatistics object.
This property is read-only.
See Also
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.
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.
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.
The QuerySelect represents the SELECT statement of the SQL used in the query definition. This can be any of the following:
The main select statement
The unions
The subqueries
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. Here, the first statement is the main statement, the second query is the SubQuery, which is the used in the criterion, and the union is the third select statement. There are fields and records 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 sub-query.
In PeopleSoft Query, the first select (that is, the Main Select) is the parent of all the unions and sub-queries. The Main Select is obtained 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
See QuerySelect Collection, QuerySelects.
In this section, we discuss each QuerySelect method. The methods are arranged in alphabetical order.
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.
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 .
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.
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 .
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.
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
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 .
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 value: 0 means the query was deleted successfully.
See Also
QuerySelect class: AddCriteria method, Criteria property.
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 .
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 value: 0 means the query was deleted successfully.
See Also
AddAllFields, QueryField Class.
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 criteria was deleted successfully.
See Also
QuerySelect class: AddHavingCriteria method, HavingCriteria property.
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 value: 0 means the query was deleted successfully.
See Also
AddQueryRecord, QueryField Class.
In this section, we discuss the QuerySelect properties. The properties are discussed in alphabetical order.
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
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.
Description
This property returns a reference to a QueryExpression Collection.
This property is read-only.
See Also
Description
This property returns a reference to a QueryCriteria collection populated with Having criteria.
This property is read-only.
See Also
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.
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
Description
This property returns a reference to a QueryRecord Collection for the query.
This is property is read-only.
See Also
Description
This property returns a reference to a QueryField Collection made up of QuerySelectedFields.
This is property is read-only.
See Also
Description
This property returns all the Query Selects that are children of the current Select Statement as a QuerySelect Collection. If the query contains Unions, the QuerySelects of the First Select contains Unions and sub-queries (if any criteria contain sub-queries). For all other selects, this property contains only the sub-queries (because PeopleSoft Query doesn't allow unions for sub-queries).
This is property is read-only.
See Also
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.
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.
A QuerySelect Collection is returned from the QuerySelects property of each QuerySelect instance. It contains the unions and sub-queries, which are children of the current Select statement. PeopleSoft Query allows Unions only with the Main Select, the QuerySelect instance for any subqueries will not have any Unions.
See QuerySelect class: QuerySelects property.
In this section, we discuss the QuerySelect collection methods. The methods are discussed in alphabetical order.
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();
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);
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();
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;
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);
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();
In this section, we discuss the Count property.
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;
A QueryRecord collection is returned from the QueryRecords QuerySelect class method.
See QuerySelect class: QueryRecords property.
In this section, we discuss each QueryRecord collection method. The methods are discussed in alphabetical order.
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();
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;
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");
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();
In this section, we discuss the Count property.
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;
A QueryRecord object is returned from the following:
The QueryRecord Collection methods First, Item, ItemByName, or Next.
The AddQueryRecord QuerySelect class method.
The QueryRecord QueryField class method.
See QueryRecord Collection, AddQueryRecord, QueryRecord.
In this section, we discuss the GetField method.
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;
In this section, we discuss each QueryRecord class property. The properties are discussed in alphabetical order.
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.
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.
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.
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.
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.
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
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.
A QueryField collection is returned from the following:
The QueryOutputFields of QuerySelect class method.
The QuerySelectedFields of QuerySelect class method.
The QueryFields QueryRecord class method.
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.
In this section, we discuss each QueryField method. The methods are discussed in alphabetical order.
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();
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;
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");
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);
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();
In this section, we discuss the Count property.
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;
A QueryField object is returned by the following:
The AddQuerySelectedField of QuerySelect class method.
The AddQueryOutputField of QuerySelect class method.
The QueryField Collection methods First, Item, ItemByName or Next.
See QuerySelect class: AddQuerySelectedField method, AddQueryOutputField method.
In this section, we discuss each QueryField method. The methods are discussed in alphabetical order.
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 .
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 .
In this section, we discuss the QueryField class properties. The properties are discussed in alphabetical order.
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.
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.
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.
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.
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.
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.
Description
This property returns the field format for the query field. This property returns a string value. This property is useful for displaying the datatype 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.
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.
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.
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.
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.
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.
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.
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");
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;
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;
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.
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.
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.
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
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
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.
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 |
7 |
%FieldType_Image |
Image |
This property is read-only.
A QueryCriteria collection is returned from the Criteria QuerySelect class property.
See QuerySelect class: Criteria property.
In this section, we discuss the QueryCriteria collection methods. The methods are discussed in alphabetical order.
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();
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 &QueryCriteriaColl.Count; &MyQueryCriteria = &QueryCriteriaColl.Item(&I); /* do processing */ End-For;
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
For &I = 1 to &QueryCriteriaColl.Count; &MyQueryCriteria = &QueryCriteriaColl.Item(&I); /* do processing */ End-For;
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();
In this section, we discuss the Count property.
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;
A QueryCriteria object is returned from the following:
The AddCriteria and AddHavingCriteria QuerySelect class method.
The First, Item, and Next method of the QueryCriteria Collection.
See QuerySelect class: AddCriteria method, AddHavingCriteria method.
See Working With Criteria and Expressions.
See Defining Selection Criteria.
In this section, we discuss the QueryCriteria class methods. The methods are discussed in alphabetical order.
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 .
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 .
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
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.
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.
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
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
In this section, we discuss the QueryCriteria class properties. The properties are discussed in alphabetical order.
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-only.
See Also
QueryCriteria class: AddExpr1Expression method.
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.
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 = &MyQueryColl.Next(); If &MyExpr1.Expr1Type = %Query_ExprField Then /* Expression is a Field */ &OldValue = &MyExpr1.Expr1Field; /* do processing */ Else /* Expression 1 is an expression */ &OldValue = &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");
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.
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.
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-only.
See Also
QueryCriteria class: AddExpr2Expression method.
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-only.
See Also
QueryCriteria class: AddExpr2Expression method.
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.
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.
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.
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.
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 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) |
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 = &MyQueryColl.Next(); 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 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 EMPLID field from the ABSENCE_HIST record whose record alias is A */ &MyField = &MyCriteria.AddExpr1Field("A", "EMPLID" );
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.
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.
Description
This property returns the name of the Query Criteria, as a string.
This property is read-only.
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-only.
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 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. |
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.
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.
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.
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.
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.
A QueryExpression Collection is returned from the Expressions Query class property.
See QuerySelect class: Expressions property.
In this section, we discuss the QueryExpression collection methods. The methods are described in alphabetical order.
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();
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;
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");
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();
In this section, we discuss the Count property.
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;
A QueryExpression object is return by the following:
The AddExpression Query class method.
The First, Item and Next methods of the QueryExpression Collection.
All of the QueryCriteria Class Methods.
The Expr1Expression and Expr2Expression1 QueryCriteria properties.
See AddExpression, QueryExpression Collection, QueryCriteria Class Methods, Expr1Expression, Expr2Expression1.
See Working With Criteria and Expressions.
In this section, we discuss the QueryExpression class properties. The properties are discussed in alphabetical order.
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.
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.
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.
Description
This property returns or sets the unique expression number, as a numeric value.
This property is read-write.
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.
Description
This property returns or sets the length of the expression, as a number.
This property is read-write.
Description
This property returns the name of the expression, as a string.
This property is read-only.
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.
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.
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.
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:
Expression containing a hint must begin with /*+.
Expression can only contain one hint. For example, only one set of /* */ is allowed in each expression.
Each /* must precede an */.
Each expression must contain a complete hint. For example, an expression can't have only /* or */. Both must be in same expression.
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 |
This property is read-write.
A QueryList Class is returned from the Expr2List property and AddExpr2List method of the QueryCriteria Class.
See QueryCriteria class: Expr2List property, AddExpr2List method.
In this section, we discuss the QueryList class methods. The methods are discussed in alphabetical order.
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);
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();
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;
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();
In this section, we discuss the Count property.
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;
A QueryListValue instance is returned from the AddListValue, First, Item, or Next QueryList Class methods.
In this section, we discuss the QueryListValue class properties. These properties are discussed in alphabetical order.
Description
This property indicates whether the value is a bind variable (such as :1). This property takes a Boolean value: True, this property is a bind variable.
This property is read-only.
Description
This property returns a string for the value stored in the list.
This property is read-only.
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.
In this section, we discuss the QueryRecordHierarchy collection methods. The methods are discussed in alphabetical order.
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();
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;
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");
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();
In this section, we discuss the QueryRecordHierarchy properties. These properties are discussed in alphabetical order.
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;
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.
In this section, we discuss the QueryRecordHierarchy class properties. The properties are discussed in alphabetical order.
Description
This property returns a description of the record node as a string.
This property is read-only.
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.
Description
This property returns the name of the record node as a string.
This property is read-only.
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.
A Query Metadata collection is returned by the Metadata Query class property.
See Query class: Metadata property.
See Using Query Metadata.
In this section, we discuss the Query Metadata collection methods. These methods are discussed in alphabetical order.
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();
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;
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");
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();
In this section, we discuss the Count property.
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;
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.
In this section, we discuss the Query Metadata class properties. The properties are discussed in alphabetical order.
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.
Description
This property returns the value for the Query Metadata property as a string.
This property is read-only.
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.
In this section, we discuss the QueryStatistics properties. The properties are discussed in alphabetical order.
Description
This property returns the average execution time for the query as a string.
This property is read-only.
Description
This property returns the average fetch time for the query as a string.
This property is read-only.
Description
This property returns the average number of rows fetched for the query.
This property is read-only.
Description
This property returns the total number of times the query has been executed.
This property is read-only.
Description
This property returns the last date and time the query was executed, as a string.
This property is read-only.
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 class: GetQuerySecurityProfile method.
In this section, we discuss the QuerySecurityProfile properties. The properties are discussed in alphabetical order.
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.
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.
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.
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.
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.
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.
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.
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.
Description
This property indicates whether the user can create or run any workflow queries. Workflow queries are of the following types:
Archive
Process
Role
This property takes a Boolean value: True, the user can create such queries.
This property is read-only.
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.
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.
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.
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.
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.
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.
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.
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.
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.
A QueryDBRecord collection is returned from the FindQueryDBRecords session method.
See Session class: FindQueryDBRecords method.
In this section, we discuss the QueryDBRecord collection methods. The methods are discussed in alphabetical order.
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();
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;
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");
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();
In this section, we discuss the Count property.
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;
A QueryDBRecord object is returned from the QueryDBRecord Collection methods First, Item, ItemByName, or Next.
In this section, we discuss the QueryDBRecord class methods. The methods are discussed in alphabetical order.
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.
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.
In this section, we discuss the QueryDBRecord class properties. The properties are discussed in alphabetical order.
Description
This property returns the description of the QueryDBRecord as a string.
This property is read-only.
Description
This property returns the name of the QueryDBRecord as a string.
This property is read-only.
Description
This property returns a reference to a QueryDBRecordField Collection.
This property is read-only.
See Also
QueryDBRecordField Collection.
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 PeopleSoft Application Designer using the Parent Record Name feature.
This property is read-only.
See Also
QueryRecordHierarchy Collection.
A QueryDBRecordField collection is returned from the QueryDBRecordFields QueryDBRecord property.
See QueryDBRecord class: QueryDBRecordFields property.
In this section, we discuss the QueryDBRecordField collection methods. The methods are discussed in alphabetical order.
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();
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;
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");
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();
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. The values are: |
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
None.
In this section, we discuss the Count property.
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;
A QueryDBRecordField object is from the QueryDBRecord Collection methods First, Item, ItemByName or Next.
In this section, we discuss the QueryDBRecordField class properties. The properties are discussed in alphabetical order.
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;
Description
This property returns the long description of the field as a string.
This is property is read-only.
Description
This property returns the Use and Edit Flags of the field, which are set when the Field is defined in PeopleSoft 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.
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.
Description
This property returns the length of the field as a number.
This property is read-only.
Description
This property returns the long name of the field as a string.
This property is read-only.
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.
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.
Description
This property returns the name of the field as a string.
This property is read-only.
Description
This property returns the short name of the field as a string.
This property is read-only.
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 |
7 |
%FieldType_Image |
Image |
This property is read-only.
A QueryPrompt collection is returned from the Prompts and RuntimePrompts Query class properties.
See Query class: Prompts property, RunTimePrompts property.
In this section, we discuss the QueryPrompt collection methods. The methods are discussed in alphabetical order.
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();
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;
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");
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();
In this section, we discuss the QueryPrompt collection properties. The properties are discussed in alphabetical order.
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;
A reference to a QueryPrompt is returned by the following:
The First, Item, ItemByName, and Next methods of a QueryPrompt Collection.
The AddPrompt Query class method.
See QueryPrompt Collection, AddPrompt.
See Defining Prompts.
In this section, we discuss the QueryPrompt properties. The properties are discussed in alphabetical order.
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.
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.
Description
This property returns the field format for a field. This property takes a number value. 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.
Description
This property returns or sets the field length.
This property is read-write.
Description
This property returns or sets the field name used with the prompt.
This property is read-write.
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.
Description
This property returns or sets the heading text for the prompt field.
This property is read-write.
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.
Description
This property returns the total count of the language records for the current prompt.
This property is read-only.
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.
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.
Description
This property returns or sets the prompt table name for the prompt field.
This property is read-write.
Description
This property returns or sets the unique prompt name for the prompt field.
This property is read-write.
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.
The following are examples of the usual actions that you perform using the Query classes.
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:
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
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");
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();
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");
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;
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.
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.
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; /* Adding query recory, adding fields, then making 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.RecordAlias, "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:
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
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;
Add Query Record in the Main Select.
Add the query record that you want to use.
&MainRec = &MainQrySel.AddQueryRecord("PSRECDEFN");
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;
Specify the OrderBy value.
Because we need to order by this field, the OrderByNumber of that field must be set also.
&QryFld.OrderByNumber = 1;
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;
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");
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();
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;
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.AddExpr2Expression1(); &SubQryExpr1.Text = "PPLTOOLS"; &SubQryCrit1.Expr2Expression1 = &SubQryExpr1;
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";
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.
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.
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)