NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-2
CASE Expression
value specified in the ELSE clause or, if ELSE is not specified, SQL sets the CASE
expression to NULL.
search-condition-1 through search-condition-n
specifies a condition to test for. If the condition is true, the CASE expression returns
the associated result value. If no search-condition is true, the CASE
expression returns the value of the ELSE clause, or NULL if ELSE is not specified.
result-1 through result-n
specifies the result value (or NULL) associated with a specific search condition. All
of the results specified in the CASE expression should have the same or comparable
data types.
result-x
specifies the value returned if none of the search conditions are true. If the ELSE
result-x clause is not specified, the CASE expression returns NULL if none of
the search conditions are true. The data type of result-x should be the same or
comparable to those of result-1 through result-n.
target-value
if present, specifies a value or expression for which a result is returned. When you
specify target-value, you use an abbreviated form of the CASE expression,
typically used for value comparisons. The data type of each value-n in the
statement should be comparable to the data type of target-value. In addition,
the collation of each value-n should be the same or comparable to the collation of
target-value.
CASE
WHEN search-condition-1 THEN { result-1 | NULL }
WHEN search-condition-2 THEN { result-2 | NULL }
WHEN search-condition-3 THEN { result-3 | NULL }
. . .
WHEN search-condition-n THEN { result-n | NULL }
[ { ELSE result-x | NULL } ]
END
or
CASE target-value
WHEN value-1 THEN { result-1 | NULL }
WHEN value-2 THEN { result-2 | NULL }
WHEN value-3 THEN { result-3 | NULL }
. . .
WHEN value-n THEN { result-n | NULL }
[ { ELSE result-x | NULL } ]
END