Routines
CASE
Synopsis
Simple case:
Searched case:
Description
The CASE
statement is an optional construct to allow conditional processing
in SQL routines.
The WHEN
clauses are evaluated sequentially, stopping after the first match,
and therefore the order of the statements is significant. The statements of the
ELSE
clause are executed if none of the WHEN
clauses match.
Unlike other languages like C or Java, SQL does not support case fall through, so processing stops at the end of the first matched case.
One or more WHEN
clauses can be used.
Examples
The following example shows a simple CASE
statement usage:
Further examples of varying complexity that cover usage of the CASE
statement
in combination with other statements are available in the SQL routines examples
documentation.