Skip to Main Content
Oracle PL/SQL Language Pocket Reference
book

Oracle PL/SQL Language Pocket Reference

by Bill Pribyl, Steven Feuerstein, Chip Dawes
April 1999
Intermediate to advanced content levelIntermediate to advanced
99 pages
2h 4m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Language Pocket Reference

Conditional and Sequential Control

PL/SQL includes conditional (IF) structures as well as sequential control (GOTO, NULL) constructs.

Conditional Control Statements

IF-THEN combination

IF condition THEN
   executable statement(s)
END IF;

For example:

IF caller_type = 'VIP' THEN
   generate_response('GOLD');
END IF;

IF-THEN-ELSE combination

IF condition THEN
   TRUE sequence_of_executable_statement(s)
ELSE
   FALSE/NULL sequence_of_executable_statement(s)
END IF;

For example:

IF caller_type = 'VIP' THEN
   generate_response('GOLD');
ELSE
   generate_response('BRONZE');
END IF;

IF-THEN-ELSIF combination

IF condition-1 THEN
   statements-1
ELSIF condition-N THEN
   statements-N
[ELSE
   else statements]
END IF;

For example:

IF caller_type = 'VIP' THEN
   generate_response('GOLD');
ELSIF priority_client THEN
   generate_response('SILVER');
ELSE
   generate_response('BRONZE');
END IF;

Sequential Control Statements

The GOTO statement performs unconditional branching to a named label. It should be used rarely. At least one executable statement must follow the label (the NULL statement can be this necessary executable statement). The format of a GOTO statement is:

GOTO label_name;

The format of the label is:

<<label_name>>

There are a number of scope restrictions on where a GOTO can branch control. A GOTO:

  • Can branch out of an IF statement, LOOP, or sub-block

  • Cannot branch into an IF statement, LOOP, or sub-block

  • Cannot branch from one section of an IF statement to another (from the IF/THEN section to the ELSE section is illegal)

  • Cannot branch ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle PL/SQL Language Pocket Reference, 5th Edition

Oracle PL/SQL Language Pocket Reference, 5th Edition

Steven Feuerstein, Bill Pribyl, Chip Dawes
Pro Oracle Spatial for Oracle Database 11g

Pro Oracle Spatial for Oracle Database 11g

Albert Godfrind, Euro Beinat, Ravi Kothuri

Publisher Resources

ISBN: 1565924576Catalog PageErrata