Input Values

Field Description
<Logical> <Logical> in the E@ statement identifies the database file and index to use to perform the call.
Record retrieval variables (also known as D@ and D# fields) Define the beginning and ending values of the last key by moving the appropriate values to the record retrieval fields named D@<KeyFieldName> and D#END#<KeyFieldName>.
E@DBSUBRNG Identify the range key by setting E@DBSUBRNG to a number that represents the position of the key field in the index (<IndexPosition>).
U@DB@AGSET(D<Prefix>@@HANDLE: DA@<Logical>:
'<Function>': '<4GLFieldName>    ': <Occurs>: 
%ADDR(D<Prefix>#AG#<FieldName>):
%ADDR(D<Prefix>#<FcnAbbr>#<FieldName>))

Use procedures to identify the columns in the table to be returned and the aggregate function to be applied. These procedure calls use the following conventions:

<Prefix> is the prefix as defined in the Database Definition utility (dbdef) for the database file being used, where <Logical> identifies the database file and index to use to access the database file. The index you refer to in the U@DB@AGSET call must match the index you refer to in the U@DB@AGINIT call.

<Function> is the type of operation you want the aggregate procedure to perform. This will be AVG for average, MIN for minimum, MAX for maximum, or SUM for a total sum.

<4GLFieldName> is the name of the field as it appears in the Database Definition utility (dbdef).

<Occurs> should be set to 1 for non-array fields, and to the number of occurrences for array fields.

<FieldName> is the name of the field as it appears in RPG code.

<FcnAbbr> is an abbreviation representing the type of operation the aggregate procedure performs (AV, MI, MA, or SU).

You can request more than one column in a single API call by using the appropriate Boolean field several times with a different field name each time, and you may specify more than one function for each call.