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.
In PL/SQL, there are only three types of blocks:
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.
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 ...