The IF statement initiates conditional processing of control file statements. It is terminated by an END IF Statement.
The logical operators NOT, AND, and OR are evaluated in standard logical order—that is, NOT first, then AND, then OR. For example, in this statement:
SELECT IF NOT USERID EQ 'USER01' AND CUSTOMER EQ 'COMPANY1' OR ACCOUNT EQ '50001000'.
AND does not extend across the OR parameter.
OR can extend across either the NOT or the AND parameter.
You can include a maximum of 12 conditions on one IF statement.
When an alphanumeric field is compared with a literal, the comparison begins with the leftmost character of the literal and the first position of the field. If the literal is shorter than the field being tested, only the number of characters in the literal is compared. Trailing characters in the field are not compared.
Multiple IF statements with no intervening END IF statements are considered to have logical ORs between them. The syntax is as follows:
IF [NOT] cond1 [{OR|AND} [NOT] cond2] ...
Reverses the result of the conditional test.
Specifies 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:
Indicates that fldname1 is a field name, fldname2 is a literal or field name, and relation is one of these logical relations:
If fldname2 is a literal it must be enclosed in single quotation marks.
Specifies that OR is required if another condition follows and AND is not used. OR is used to logically connect the conditions so that the statements between the IF and the END IF statements are executed if any of the conditions are true.
Specifies that AND is required if another condition follows and OR is not used. AND is used to logically connect the conditions so that the statements between the IF and the END IF statements are executed if all of the conditions are true.
Specifies that cond2 defines an additional conditional expression in the same format as cond1. Up to 12 AND clauses or OR clauses may be specified.
Examples
This statement checks to see if the expiration date equals 10365:
IF EXPDT EQ '10365'.
This statement checks to see if the CA VM:Account record type is 01 or 03:
IF RECTYPE EQ '01' OR RECTYPE EQ '03'.
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |