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.
- Variable-length fields used by the INCREL parameter
You can use variable-length character fields for the INCREL parameter. Enter the character value without the 2-byte length field. The length of the data that is entered determines the number of bytes that are used for the comparison.
- Date, time, and timestamp fields used by the INCREL parameter
The INCREL parameter allows date, time, and timestamp fields. The copy command compares the input field value chronologically to the value in the date, time, or timestamp field to determine if it should select the record.
- Null-capable fields used by the INCREL parameter
The INCREL parameter allows a value of *NULL as input for a field value. You can use the *EQ and *NE operators with the *NULL value to test whether a field in a database file contains the null value or not.
- Different CCSIDs used by the INCREL parameter
The copy command assumes that the input string for character, DBCS-open, DBCS-either, or DBCS-only fields are in the CCSID of the job in which the copy command is running. The input string is converted to the CCSID of the from-field.
- DBCS-graphic fields used by the INCREL parameter
When you specify a graphic field for the INCREL parameter, you should enclose the DBCS data in shift-out and shift-in characters. The copy command assumes that the data is in the associated DBCS CCSID of the job CCSID.
Parent topic:
Selecting the records to copy