CASE expression uses one or more Boolean expressions to determine the resulting value to return.
boolean-expression is evaluated in the order in which it appears in the
result is an expression that is type-compatible in the context where the
CASE expression is used.
- When the first
boolean-expression is encountered that evaluates to
result in the corresponding
THEN clause is returned as the value of the
- If none of
boolean-expression evaluates to true, then
ELSE is returned.
- If no
ELSE is specified, the
CASE expression returns null.
This example uses a searched
CASE expression to assign the department name to a variable based on the department number:
The following is the output from this program: