A searched CASE statement uses one or more Boolean expressions to determine the resulting set of statements to execute.
Syntax
boolean-expression is evaluated in the order in which it appears in the CASE statement.
When the first boolean-expression is encountered that evaluates to TRUE, the statements in the corresponding THEN clause are executed and control continues following the END CASE keywords.
If none of boolean-expression evaluates to TRUE, the statements following ELSE are executed.
If none of boolean-expression evaluates to TRUE and there is no ELSE clause, an exception is thrown.
Example
This example uses a searched CASE statement to assign a department name and location to a variable based on the department number: