Creating a PL/SQL Block-1
The interactions in this eCourse require Javascript to be enabled.
Creating a PL/SQL Block: Part 1
previous|next
The basic construct in PL/SQL is a block. A block consists of a set of
SQL and/or PL/SQL statements, joined together and passed to the Oracle
engine all in one go.
A PL/SQL Block consists of three sections:
Declarative (optional): This section begins
with the keyword DECLARE and
ends when your executable section starts.
Executable (required): This section begins with the
keyword BEGIN and ends
with END. The keyword
END should end
with a semicolon.
Exception handling (optional): The exception section
is nested in the executable section. This section begins with the
keyword EXCEPTION.
Section
Description
Declarative(DECLARE)
Contains declarations of
all variables, constants, cursors, and user-defined exceptions that
are referenced in the executable and exception sections
Executable(BEGIN...END)
Contains SQL statements to
retrieve data from the database and PL/SQL statements to manipulate
data in the block
Exception(EXCEPTION)
Specifies the actions to
perform when errors and abnormal conditions arise in the executable
section