Skip Headers
Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)

Part Number E25519-05
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub
LNPLS01304

CASE Statement

The CASE statement chooses from a sequence of conditions and runs a corresponding statement.

The simple CASE statement evaluates a single expression and compares it to several potential values.

The searched CASE statement evaluates multiple Boolean expressions and chooses the first one whose value is TRUE.

LNPLS1069Topics

Syntax

LNPLS982simple_case_statement ::=

Description of simple_case_statement.gif follows
Description of the illustration simple_case_statement.gif

LNPLS983searched_case_statement ::=

Description of searched_case_statement.gif follows
Description of the illustration searched_case_statement.gif

See:

Semantics

LNPLS1070simple_case_statement

LNPLS1072selector

Expression whose value is evaluated once and used to select one of several alternatives. selector can have any PL/SQL data type except BLOB, BFILE, or a user-defined type.

LNPLS1073WHEN selector_value THEN statement

selector_value can be an expression of any PL/SQL type except BLOB, BFILE, or a user-defined type.

The selector_values are evaluated sequentially. If the value of a selector_value equals the value of selector, then the statement associated with that selector_value runs, and the CASE statement ends. Subsequent selector_values are not evaluated.

Caution:

A statement can modify the database and invoke nondeterministic functions. There is no fall-through mechanism, as there is in the C switch statement.

LNPLS1075ELSE statement [statement ]...

The statements run if and only if no selector_value has the same value as selector.

Without the ELSE clause, if no selector_value has the same value as selector, the system raises the predefined exception CASE_NOT_FOUND.

LNPLS1076label

A label that identifies the statement (see "statement ::=" and "label").

LNPLS1077searched_case_statement

LNPLS1078WHEN boolean_expression THEN statement

The boolean_expressions are evaluated sequentially. If the value of a boolean_expression is TRUE, the statement associated with that boolean_expression runs, and the CASE statement ends. Subsequent boolean_expressions are not evaluated.

Caution:

A statement can modify the database and invoke nondeterministic functions. There is no fall-through mechanism, as there is in the C switch statement.

LNPLS1079ELSE statement [statement ]...

The statements run if and only if no boolean_expression has the value TRUE.

Without the ELSE clause, if no boolean_expression has the value TRUE, the system raises the predefined exception CASE_NOT_FOUND.

LNPLS1080label

A label that identifies the statement (see "statement ::=" and "label").

Examples

Related Topics

LNPLS1081In this chapter:

LNPLS1082In other chapters:

See Also:

Reader Comment

   

Comments, corrections, and suggestions are forwarded to authors every week. By submitting, you confirm you agree to the terms and conditions. Use the OTN forums for product questions. For support or consulting, file a service request through My Oracle Support.

Hide Navigation

Quick Lookup

Database Library · Master Index · Master Glossary · Book List · Data Dictionary · SQL Keywords · Initialization Parameters · Advanced Search · Error Messages

Main Categories

This Document

New and changed documents:
RSS Feed HTML RSS Feed PDF