Specifying a Related Field Using Aggregate Functions

Note: Fields from directly related files may be used as values, but you cannot use fields from other indirectly related files that are not directly specified in the relationship.

To supply a value from a related field, use the form

relation@function(field)

where

Parameter Description
field

Use the format fieldname{[occurrence]}, where occurrence is optional and specifies the number of occurrences for the field.

For example:

CAPFLD[3]

Note: The square brackets enclose the number of occurrences.
function

Optional.

One of the following aggregate functions: MIN, MAX, AVG, or SUM.

relation

A relationship name as defined in the primary file being updated. The file being updated must be the primary file in the relationship.

Note: If the related field returns no values and the field to be updated can not be NULL, the update will fail.

Example: One-to-One Relationship

The following example requires the relationship RELHR be a One-to-One to the database file being updated.

Field = RELHR@EMPLOYEE

Example: One-to-Many Relationship

The following example updates from multiple records in the related file.

Field = RELHR@SUM(SALARY[1])