23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CASE<br />

CASE<br />

Syntax<br />

80<br />

• The argument to the function must be of type SMALLINT, INTEGER, NUMERIC, REAL, or<br />

FLOAT.<br />

• The result is of type NUMERIC.<br />

Specifies a series of search conditions and associated result expressions. The general form is<br />

called a searched case expression. <strong>SQL</strong> returns the value specified by the first result expression<br />

whose associated search condition evaluates as true. If none of the search conditions evaluates<br />

as true, the CASE expression returns a NULL value, or the value of some other default expression<br />

if the CASE expression includes the ELSE clause.<br />

CASE also supports syntax for a shorthand notation, called a simple case expression, for<br />

evaluating whether one expression is equal to a series of other expressions.<br />

searched_case_expr | simple_case_expr<br />

searched_case_expr<br />

simple_case_expr<br />

CASE<br />

Syntax<br />

CASE<br />

WHEN search_condition THEN { result_expr | NULL }<br />

[ ... ]<br />

[ ELSE expr | NULL ]<br />

END<br />

Syntax<br />

CASE primary_expr<br />

WHEN expr THEN { result_expr | NULL }<br />

[ ... ]<br />

[ ELSE expr | NULL ]<br />

Specifies a searched case expression. It must be followed by one or more WHEN-THEN<br />

clauses, each specifying a search condition and corresponding expression.<br />

WHEN search_condition THEN { result_expr | NULL }<br />

Specifies a search condition and corresponding expression. <strong>SQL</strong> evaluates<br />

search_condition. If search_condition evaluates as true, CASE returns the value<br />

specified by result_expr, or NULL, if the clause specifies THEN NULL.<br />

If search_condition evaluates as false, <strong>SQL</strong> evaluates the next WHEN-THEN clause, if any,<br />

or the ELSE clause, if it is specified.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!