Executes the frist statement block whose condition is true.
The CFL Case statement is similar to the CCL CASE expression, but uses Sybase CEP Function Language components in its conditions and THEN and ELSE clauses, and is limited in scope according to the same rules as other block CFL statements.
The Case statement specifies one or more WHEN clauses, each of which contains a Boolean condition and a THEN subclause with a block of CFL statements. The WHEN clauses are evaluated in sequence.
The first clause that evaluates to true executes the block of statements associated with its THEN subclause. All subsequent WHEN clauses are then ignored.
If none of the WHEN clause conditions are true, the statements associated with the ELSE clause (if one is specified) are executed.
If no ELSE clause exists and none of the WHEN clause conditions are true, no statements are executed.
If Statement
The following example defines three cases, which result in a return of -1, 0, or 1, depending on the value of the passed-in parameter.
CREATE FUNCTION Compare(Value INTEGER) RETURNS INTEGER CASE WHEN Value < 0 THEN RETURN -1 WHEN Value =0 THEN RETUNRN 0; ELSE RETURN 1; END CASE; END FUNCTION;