Syntax:
CASE case_value
    WHEN when_value THEN statement_list
    [WHEN when_value THEN statement_list] ...
    [ELSE statement_list]
END CASE

Or:

CASE
    WHEN search_condition THEN statement_list
    [WHEN search_condition THEN statement_list] ...
    [ELSE statement_list]
END CASE

The CASE statement for stored routines implements a complex conditional
construct. If a search_condition evaluates to true, the corresponding
SQL statement list is executed. If no search condition matches, the
statement list in the ELSE clause is executed. Each statement_list
consists of one or more statements.

Note: The syntax of the CASE statement shown here for use inside stored
routines differs slightly from that of the SQL CASE expression
described in [control-flow-functions]. The CASE statement cannot have
an ELSE NULL clause, and it is terminated with END CASE instead of END.
