Declaring block relationships v16
You can declare the relationship between blocks in an SPL program. The ability to invoke subprograms and access identifiers declared in a block depends on this relationship.
The following are 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, and subprocedures and subfunctions.
- An identifier (variable, cursor, type, or subprogram) local to a block means that it's declared in the declaration section of the given block. You can access such local identifiers from the executable section and optional exception section of the block.
- The parent block contains the declaration of another block, that is, 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 (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 in the declaration section of this procedure are all at the same level, such as level 1. Additional subprograms in the declaration section of the subprograms declared in the standalone procedure are at the next level, that 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 at the same level relative to each other.
The following schematic of a set of procedure declaration sections 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 there are two pairs of sibling blocks.
block_1b is one pair, and
block_2b is 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_3. The second is
block_2b. The third is
The rules for invoking subprograms based on block location are described starting with Invoking subprograms. The rules for accessing variables based on block location are described in Accessing subprogram variables.