2.3. Introduction to Program Structure
My son, now eight, is a Lego fanatic. While many of his new-fangled, special-purpose Lego components are in many ways different from the simple bricks I had as a child, the idea of constructing from parts is the same. I think humans find something comforting about assembling objects of similar size, shape, and function into useful artifacts. As a grown-up programmer I'm still, after a fashion, playing with blocks.
2.3.1. More About Blocks
In PL/SQL, there are only three types of blocks:
Anonymous blocks
Procedures
Functions
We've already seen a simple anonymous block—that is, one without a name—in the "hello, world" example. The other two types of blocks, procedures and functions, are similar but also include a header.
There are actually four possible components of a PL/SQL block:
The definition of its interface (that is, information such as its name that will be needed to invoke it later)
Some number of variables
A sequence of statements (which may include SQL statements) intended to solve some problem or perform some action
A way to recover from "issues"
These components are organized into sections inside the block, as illustrated in Figure 2-1.
Figure 2-1. Representation of a named PL/SQL block

Although there are places other than blocks where PL/SQL can exist, I'll introduce those in later chapters. The next two sections will give ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access