Use the SELECT statement for conditional processing. If a record passes the specified condition, it is processed. If a record fails the condition, it is passed to the next SELECT or IGNORE statement. If there are no more SELECT or IGNORE STATEMENTS in the file, the record is rejected, and the next record is read and tested.
VMRGRW uses the following rules for processing IGNORE and SELECT statements:
- If a record passes an IGNORE test, all further tests and processing are ignored, and a new record is read.
- If a record fails an IGNORE test, it is passed to the next SELECT or IGNORE statement.
- If a record passes a SELECT test, subsequent SELECT or IGNORE tests are bypassed and the record is processed using the criteria defined in the SELECT statement the record passed.
- If the record fails a SELECT test, it is passed to the next SELECT or IGNORE statement.
- If a record fails all SELECT and IGNORE tests, it is treated opposite to the last statement in the group. That is, if the last statement is SELECT, the record is ignored, and if the last statement is IGNORE, the record is selected.
SELECT statements are executed immediately after the record is read, after any NOW MOVE and NOW COMPUTE statements, and before any other processing. If you want to select a record after some processing, use the NEXT RECORD statement with the IF and END IF statements.
All SELECT and IGNORE statements in your control file must be entered consecutively. They cannot be separated by any other statements.
The syntax is as follows:
SELECT IF [NOT ] cond1 [{OR|AND} [NOT] cond2] ...
- NOT
Reverses the result of the conditional test. - cond1
Indicates that cond1 is required and must be in one of two formats. One format is described in the section Bit Test Statement. The other format is: - fldname1 relation fldname2
Indicates fldname1 is the field name, fldname2 is a literal or field name, and relation is one of these logical relations:- EQ equal to
- NE not equal to
- GT greater than
- LT less than
- OR
Indicates that OR is required if another condition follows and AND is not used. OR is used to logically connect the conditions so that the record is selected if any of the conditions are true. A maximum of 12 AND or OR clauses may be specified. - AND
Indicates that AND is required if another condition follows and OR is not used. AND is used to logically connect the conditions so that the record is selected only if all conditions are true. A maximum of 12 AND or OR clauses may be specified.
Example
This statement selects a record if the volser is 200001:
SELECT IF VOLSER EQ '200001'.