EasyManua.ls Logo

Sybase Adaptive Server Anywhere - CASE Statement

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CASE statement
412
CASE statement
Use this statement to select an execution path based on multiple cases.
CASE
value-expression
WHEN [
constant
| NULL ] THEN
statement-list
… [ WHEN [
constant
| NULL ] THEN
statement-list
] …
ELSE
statement-list
END CASE
None.
None.
"BEGIN statement" on page 404
"Using Procedures, Triggers, and Batches" on page 435 of the book ASA
User’s Guide
The CASE statement is a control statement that allows you to choose a list of
SQL statements to execute based on the value of an expression. The value-
expression is an expression that takes on a single value, which may be a
string, a number, a date, or other SQL data type. If a WHEN clause exists for
the value of value-expression, the statement-list in the WHEN clause is
executed. If no appropriate WHEN clause exists, and an ELSE clause exists,
the statement-list in the ELSE clause is executed. Execution resumes at the
first statement after the END CASE.
CASE statement is different from CASE expression
Do not confuse the syntax of the CASE statement with that of the CASE
expression.
$ For information on the CASE expression, see "CASE expressions"
on page 233.
SQL/92 Persistent Stored Module feature.
Sybase Not supported by Adaptive Server Enterprise.
The following procedure using a case statement classifies the products listed
in the product table of the sample database into one of shirt, hat, shorts, or
unknown.
The following procedure uses a case statement to classify the results of a
query.
CREATE PROCEDURE ProductType (IN product_id INT, OUT
type CHAR(10))
BEGIN
DECLARE prod_name CHAR(20);
Function
Syntax
Permissions
Side effects
See also
Description
Standards and
compatibility
Example

Table of Contents

Related product manuals