IF...THEN ... ELSE

From InterBase

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 TRUE, FALSE, or UNKNOWN; must be enclosed in parentheses

THEN <compound_statement>

Statement or block executed if <condition> is TRUE

ELSE<compound_statement>

Optional statement or block executed if <condition> is not TRUE

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;
. . .

See Also

Advance To: