This topic describes the terminology of the relationship between blocks that can be declared in an SPL program. The ability to invoke subprograms and access identifiers declared within a block depends upon this relationship.

The following content describes the basic terms:

  • A block is the basic SPL structure consisting of an optional declaration section, a mandatory executable section, and an optional exception section. Blocks implement standalone procedure and function programs, anonymous blocks, triggers, packages, subprocedures, and subfunctions.
  • An identifier (variable, cursor, type, or subprogram) local to a block means that it is declared within the declaration topic of the given block. Such local identifiers are accessible from the executable section and optional exception section of the block.
  • The parent block contains the declaration of another block (the child block).
  • Descendent blocks are the set of blocks forming the child relationship starting from a given parent block.
  • Ancestor blocks are the set of blocks forming the parental relationship starting from a given child block.
  • The set of descendent (or ancestor) blocks form a hierarchy.
  • The level is an ordinal number of a given block from the highest ancestor block. For example, given a standalone procedure, the subprograms declared within the declaration topic of this procedure are all at the same level. For example, call this procedure at level 1. Additional subprograms within the declaration topic of the subprograms declared in the standalone procedure are at the next level which is level 2.
  • The sibling blocks are the set of blocks that have the same parent block (that is, they are all locally declared in the same block). Sibling blocks are also always at the same level relative to each other.

The following schematic of a set of procedure declaration topics provides an example of a set of blocks and their relationships to their surrounding blocks.

The two vertical lines on the left-hand side of the blocks indicate that two pairs of sibling blocks exist. block_1a and block_1b are one pair, and block_2a and block_2b are the second pair.

The relationship of each block with its ancestors is shown on the right-hand side of the blocks. Three hierarchical paths are formed when progressing up the hierarchy from the lowest level child blocks. The first consists of block_0, block_1a, block_2a, and block_3. The second is block_0, block_1a, and block_2b. The third is block_0, block_1b, and block_2b.

CREATE PROCEDURE block_0
IS
        .
    +---- PROCEDURE block_1a    ------- Local to block_0
    |     IS
    |         .                          |
    |         .                          |
    |         .                          |
    |     +-- PROCEDURE block_2a   ---- Local to block_1a and descendant
    |     |   IS                          of block_0
    |     |       .                      |
    |     |       .                      |
    |     |       .                      |
    |     |      PROCEDURE block_3   -- Local to block_2a and descendant
    |     |      IS                       of block_1a, and block_0
    | Siblings        .                  |
    |     |           .                  |
    |     |           .                  |
    |     |       END block_3;           |
    |     |   END block_2a;              |
    |     +-- PROCEDURE block_2b   ---- Local to block_1a and descendant
    |     |   IS                          of block_0
 Siblings |       ,                      |
    |     |       .                      |
    |     |       .                      |
    |     +-- END block_2b;              |
    |                                    |
    |     END block_1a;         ---------+
    +---- PROCEDURE block_1b;   ------- Local to block_0
    |     IS
    |         .                          |
    |         .                          |
    |         .                          |
    |         PROCEDURE block_2b   ---- Local to block_1b and descendant
    |         IS                          of block_0
    |             .                      |
    |             .                      |
    |             .                      |
    |         END block_2b;              |
    |                                    |
    +---- END block_1b;         ---------+
BEGIN
      .
      .
      .
END block_0;