start page | rating of books | rating of authors | reviews | copyrights

Oracle PL/SQL Language Pocket Reference

Oracle PL/SQL Language Pocket ReferenceSearch this book
Previous: 1.5 Variables and Program Data Chapter 1
Oracle PL/SQL Language Pocket Reference
Next: 1.7 Loops
 

1.6 Conditional and Sequential Control

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

1.6.1 Conditional Control Statements

1.6.1.1 IF-THEN combination

IF condition THEN    executable statement(s) END IF;

For example:

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

1.6.1.2 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;

1.6.1.3 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;

1.6.2 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:

The NULL statement is an executable statement that does nothing. It is useful when an executable statement must follow a GOTO label or to aid readability in an IF-THEN-ELSE structure. For example:

IF :report.selection = 'DETAIL' THEN    exec_detail_report; ELSE    NULL; END IF;


Previous: 1.5 Variables and Program Data Oracle PL/SQL Language Pocket Reference Next: 1.7 Loops
1.5 Variables and Program Data   1.7 Loops

The Oracle Library Navigation

Copyright (c) 2000 O'Reilly & Associates. All rights reserved.

Library Home Oracle PL/SQL Programming, 2nd. Ed. Guide to Oracle 8i Features Oracle Built-in Packages Advanced PL/SQL Programming with Packages Oracle Web Applications Oracle PL/SQL Language Pocket Reference Oracle PL/SQL Built-ins Pocket Reference