How to: |
The IF phrase selects records to be included in a report, and offers a subset of the functionality of WHERE. For a list of supported IF operators, see Using Operators in Record Selection Tests.
Tip: Unless you specifically require IF syntax (for example, to support legacy applications), we recommend using WHERE.
IF fieldname operator literal [OR literal]
where:
Note that all literals that contain blanks (for example, New York City) and all date and date-time literals must be enclosed within single quotation marks.
Note: The IF phrase alone cannot be used to create compound expressions by connecting simple expressions with AND and OR logical operators. Compound logic requires that the IF phrase be used with the DEFINE command, as described in Using Expressions. You can accomplish this more easily with WHERE. See Using Compound Expressions for Record Selection.
You can use as many IF phrases as necessary to define all your selection criteria, as illustrated in the following example:
TABLE FILE EMPLOYEE PRINT EMP_ID LAST_NAME IF SALARY GT 20000 IF DEPARTMENT IS MIS IF LAST_NAME IS CROSS OR BANNING END
All of these criteria must be satisfied in order for a record to be included in a report. The output is:
EMP_ID LAST_NAME ------ --------- 818692173 CROSS