Selecting records based on field value (INCREL parameter)

 

You use the INCREL parameter to select records for copying by testing for the value of an entire field. Unlike the INCCHAR parameter, you can use the INCREL parameter only when you are copying from a database file, and you can test for different values in different fields on one copy command.

You can use this parameter on the CPYF command only. You can use as many as 50 AND and OR relationships on one INCREL parameter. The OR relationship groups the AND relationships. For example, the following INCREL parameter essentially says this: If field FLDA is greater than 5 and field FLDB is less than 6, select the record. If FLDB is equal to 9 (FLDA is any value), select the record.

INCREL((*IF FLDA *GT 5) (*AND FLDB *LT 6) +
  (*OR FLDB *EQ 9))

The value you specify must be compatible with the field type. You must enclose each INCREL relational set in parentheses.

The value *IF must be specified as the first value in the first set of comparison values, if there is only one set or several sets of comparison values. If more than one set of comparison values are specified, either *AND or *OR must be specified as the first value in each set after the first set of values.

In the following discussion, an IF group refers to an IF set, optionally followed by one or more AND sets. An OR group refers to an OR set, optionally followed by one or more AND sets. All the comparisons specified in each group are done until a complete group, which is a single IF set or OR set having no AND sets following it, yields all true results. If at least one group has a true result, the copy command includes the record in the copied file.

The first set of comparison values (*IF field-name operator value) and any AND sets logically connected with the IF set are evaluated first. If the results in all of the sets in the IF group are true, the testing ends and the record is copied. If any of the results in the IF group are false and an OR group follows, another comparison begins. The command evaluates the OR set and any AND sets that follow it (up to the next OR set). If the results in the OR group are all true, the record is included. If any result is false and another OR group follows, the process continues until either an OR group is all true or until there are no more OR groups. If the results are not all true for any of the IF or OR groups, the record is excluded (not copied to the to-file).

If you specify both the INCCHAR and INCREL parameters, the copy command copies a record only if it satisfies both the INCCHAR and INCREL conditions.

You cannot specify the INCREL parameter if you specify RCDFMT(*ALL) when copying from a multiple-format logical file.

For binary character fields, the INCREL parameter will only allow checks for *EQ and *NE.

 

Parent topic:

Selecting the records to copy