PL/SQL Architecture:
Before discussing the architecture of a PL/SQL block the basic unit of a PL/SQL that is a block wants to be understood. The PL/SQL block holds three categories:
- Declarative part
- Executable part
- Error handling part
Declarative Part
Declarative part is the first section of a PL/SQL block. It is used to declare variables and constants. Each declaration or definition has a memory allocated in the session's memory. A keywords DECLARE represents this part.
Syntax:
DECLARE
Set of variables
Executable Part
Executable part holds all the SQL and PL/SQL statements that are used for processing and querying the data. BEGIN is used to mark the starting of the block and END ends the block. Here must be at least one executable statement within a group of BEGIN and END statements.
Error handling part
Error handling part is known as Exception. It contains the error handling statements. An Oracle takes the control from the execution part to this part whenever any error is increased in the program and checks for the exception.