A searched CASE expression uses one or more Boolean expressions to determine the resulting value to return.
Syntax
boolean-expression is evaluated in the order in which it appears in the CASE expression.
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 TRUE, result in the corresponding THEN clause is returned as the value of the CASE expression.
If none of boolean-expression evaluates to true, then result following ELSE is returned.
If no ELSE is specified, the CASE expression returns null.
Example
This example uses a searched CASE expression to assign the department name to a variable based on the department number: