IF

The IF statement executes a group of statements conditionally. It can switch program control conditionally between two blocks of statements.

4GLREF00000151.gif

statement is an SQL statement or other 4GL statement.

If the Boolean expression is TRUE, 4GL executes the block of statements following the THEN keyword, until it reaches either the ELSE keyword or the END IF keywords. 4GL then resumes execution after the END IF keywords.

If the Boolean expression is FALSE, 4GL executes the block of statements between the ELSE keyword and the END IF statement. If you omit the ELSE keyword, 4GL resumes execution with the statement following the END IF keywords. The Boolean expression is treated as FALSE if it contains a NULL value anywhere (except as the operand of the IS NULL operator).

If you have a set of nested IF statements, all testing the same value, consider using a CASE statement.

References

CASE

FOR

WHENEVER

WHILE