PL/SQL - Conditional Statements

Conditional Statements

The following code segment shows the IF-THEN-ELSIF construct. The ELSIF and ELSE parts are optional so it is possible to create simpler IF-THEN or, IF-THEN-ELSE constructs.

IF x = 1 THEN sequence_of_statements_1; ELSIF x = 2 THEN sequence_of_statements_2; ELSIF x = 3 THEN sequence_of_statements_3; ELSIF x = 4 THEN sequence_of_statements_4; ELSIF x = 5 THEN sequence_of_statements_5; ELSE sequence_of_statements_N; END IF;

The CASE statement simplifies some large IF-THEN-ELSE structures.

CASE WHEN x = 1 THEN sequence_of_statements_1; WHEN x = 2 THEN sequence_of_statements_2; WHEN x = 3 THEN sequence_of_statements_3; WHEN x = 4 THEN sequence_of_statements_4; WHEN x = 5 THEN sequence_of_statements_5; ELSE sequence_of_statements_N; END CASE;

CASE statement can be used with predefined selector:

CASE x WHEN 1 THEN sequence_of_statements_1; WHEN 2 THEN sequence_of_statements_2; WHEN 3 THEN sequence_of_statements_3; WHEN 4 THEN sequence_of_statements_4; WHEN 5 THEN sequence_of_statements_5; ELSE sequence_of_statements_N; END CASE;

Read more about this topic:  PL/SQL

Famous quotes containing the words conditional and/or statements:

    Computer mediation seems to bathe action in a more conditional light: perhaps it happened; perhaps it didn’t. Without the layered richness of direct sensory engagement, the symbolic medium seems thin, flat, and fragile.
    Shoshana Zuboff (b. 1951)

    There is a certain embarrassment about being a storyteller in these times when stories are considered not quite as satisfying as statements and statements not quite as satisfying as statistics; but in the long run, a people is known, not by its statements or its statistics, but by the stories it tells.
    Flannery O’Connor (1925–1964)