PL/SQL
PL/SQL stands for Procedural Language/SQL.
- It is the Oracle procedural language extension of SQL.
- PL/SQL combines SQL with the procedural functionality of a structured programming language, such as
IF ...THEN
, WHILE
, and LOOP
.
- Even when PL/SQL is not stored in the database, applications can send blocks of PL/SQL to the database rather than individual SQL statements, thereby reducing network traffic.
The following PL/SQL topics will be discussed:
- Basic structure of PL/SQL
- Variables and types
- Simple PL/SQL programs
- Control flow in PL/SQL
|
- Cursors
- Procedures
- Discovering errors
- Printing variables
|
Basic Structure of PL/SQL
The basic unit in PL/SQL is a block.
All PL/SQL programs are made up of blocks, which can be nested within each other.
Typically, each block performs a logical action in the program.
A block has the following structure:
DECLARE
/* Declarative section:
variables, types, and local subprograms. */
BEGIN
/* Executable section:
procedural and SQL statements go here. */
EXCEPTION
/* Exception handling section:
error handling statements go here. */
END;
The executable section is required; the other sections are optional.