IF...THEN ... ELSE
Go Up to Procedures and Triggers
Conditional statement that performs a block or statement in the IF clause if the specified condition is TRUE, otherwise performs the block or statement in the optional ELSE clause. Available in triggers and stored procedures.
IF (<condition>)
THEN <<compound_statement>>
[ELSE <<compound_statement>>]
| Argument | Description |
|---|---|
|
<condition> |
Boolean expression that evaluates to |
|
|
Statement or block executed if <condition> is |
|
|
Optional statement or block executed if <condition> is not |
Description: The IF … THEN … ELSE statement selects alternative courses of action by testing a specified condition.
<condition> is an expression that must evaluate to TRUE to execute the statement or block following THEN. The optional ELSE clause specifies an alternative statement or block executed if <condition> is not TRUE.
Example: The following lines of code illustrate the use of IF… THEN, assuming the variables LINE2, FIRST, and LAST have been previously declared:
. . .
IF (FIRST IS NOT NULL) THEN
LINE2 = FIRST || ' ' || LAST;
ELSE
LINE2 = LAST;
. . .