The CASE expression
selects values if certain conditions are met. The
case-expression argument
returns a single value that is conditionally evaluated for each row
of a table. Use the WHEN-THEN clauses to execute a CASE expression
for some, but not all of the rows in the table that is being queried
or created. The optional ELSE expression gives an alternative action
if no THEN expression is executed.
When you omit
case-expression,
when-expression is
evaluated as a Boolean (true or false) value. If
when-expression returns
a nonzero, non-null result, then the WHEN clause is true. If
case-expression is
specified, then it is compared with
when-expression for
equality. If
case-expression equals
when-expression,
then the WHEN clause is true.
If the
when-expression is
true for the row that is being executed, then the
result-expression that
follows THEN is executed. If
when-expression is
false, then FedSQL evaluates the next
when-expression until
they are all evaluated. If every
when-expression is
false, then FedSQL executes the ELSE expression, and its result becomes
the CASE expression's result. If no ELSE expression is present
and every
when-expression is
false, then the result of the CASE expression is null.
You can use a CASE expression
as an item in the SELECT clause and as either operand in an SQL expression.