Technical Training
Oracle 9i TrainingOracle 9i PL/SQL Control Structures
Control Structures
This chapter teaches about how to structure flow of control through a PL/SQL program. The control structures of PL/SQL are simple yet powerful. Control structures in PL/SQL can be divided into selection or conditional, iterative and sequential.
Conditional Control (Selection): This structure tests a condition, depending on the condition is true or false it decides the sequence of statements to be executed. Example
IF-THEN, CASE and searched CASE statements.
Syntax for IF-THEN
IF
Statements
END IF;
Example:

IF-THEN-ELSE:
IF
Statements
ELSE
statements
END IF;
Example:

IF-THEN-ELSIF:
IF
Statements
ELSIF
Statements
ELSE
Statements
END IF;

Iterative Control
LOOP statement executes the body statements multiple times. The statements are placed between LOOP – END LOOP keywords.
The simplest form of LOOP statement is an infinite loop. EXIT statement is used inside LOOP to terminate it.
Syntax for LOOP- END LOOP
LOOP
Statements
END LOOP;
Example:
BEGIN
LOOP
DBMS_OUTPUT.PUT_LINE (‘Hello’);
END LOOP;
END;

Labeling Loops
We can label Loops. A Label is undeclared identifier enclosed between double angle brackets( Ex. <

Oracle 9i Training
- Oracle 9i Utilities
- Oracle 9i Packages
- Oracle 9i Database Triggers
- Oracle 9i Procedures and Functions
- Oracle 9i PL/SQL Collections
- Oracle 9i Exception Handling
- Download example SQL Scripts used in Oracle 9i Tutorials
- Oracle 9i Cursors
- Oracle 9i PL/SQL Control Structures
- Building PL/SQL Blocks in Oracle 9i
- Oracle 9i Tables and Constraints
- More Oracle 9i Database Objects
- Introduction to Oracle 9i SQL, PLSQL, and SQL *Plus
- Oracle 9i Software Installation, SQL, PLSQL and SQL *Plus References







