Creating a subprocedure v14
The PROCEDURE
clause specified in the declaration section defines and names a subprocedure local to that block.
The term block refers to the SPL block structure consisting of an optional declaration section, a mandatory executable section, and an optional exception section. Blocks are the structures for standalone procedures and functions, anonymous blocks, subprograms, triggers, packages, and object type methods.
The phrase the identifier is local to the block means that the identifier (that is, a variable, cursor, type, or subprogram) is declared in the declaration section of that block. Therefore, the SPL code can access it in the executable section and optional exception section of that block.
You can declare subprocedures only after all the other variable, cursor, and type declarations included in the declaration section. Subprograms must be the last set of declarations.
Where:
name
is the identifier of the subprocedure.parameters
is a list of formal parameters.PRAGMA AUTONOMOUS_TRANSACTION
is the directive that sets the subprocedure as an autonomous transaction.declarations
are variable, cursor, type, or subprogram declarations. If subprogram declarations are included, you must declare them after all other variable, cursor, and type declarations.statements
are SPL program statements. TheBEGIN - END
block can contain anEXCEPTION
section.
Examples
This example is a subprocedure in an anonymous block:
Invoking this anonymous block produces the following output:
This example is a subprocedure in a trigger:
Invoking this trigger produces the following output:
- On this page
- Examples