Previous Next Chapter

WHEN

WHEN expression [THEN [;] [conditional statement]]

The WHEN instruction is similar to the IF instruction, but is valid only within a SELECT range. Each WHEN expression is evaluated in turn and must result in a Boolean value. If the result is a 1, the conditional statement is executed and control passes to the END statement that terminates the SELECT. As with the IF instruction, the THEN need not be part of the same clause. For example:

SELECT
WHEN i<j THEN SAY `less'
WHEN i=j THEN SAY `equal'
OTHERWISE SAY `greater'
END

Top Previous Next Chapter