Initialization of modules using the SYS_INIT procedure

Initialization of a module refers to the setting up of module objects and related default values that is possible when a defined module initialization procedure is executed. A module initialization procedure is an SQL procedure defined within the module with the reserved named SYS_INIT. Actions typically performed by an initialization procedure include initialization of variables, opening of cursors and creation of temporary tables.

Once a procedure named SYS_INIT is defined for a module, this procedure is implicitly called upon the first reference to either a published module routine or a published global variable defined within the module. It can also be explicitly called by executing the CALL statement from within a module object or from outside of the module.

The purpose of the SYS_INIT procedure is to provide support for:
  • Initializing variables defined in the module.
  • Initializing and opening cursors associated with cursor variables defined in the module.
  • Creating global temporary tables.
  • Calling other procedures that contain initialization logic.

The SYS_INIT procedure definition can be added to a module using the ALTER MODULE statement in the same way as other procedures are added to modules.

The SYS_INIT procedure definition can contain all supported SQL PL and SQL statements.

The SYS_INIT procedure definition cannot have parameters.

The SYS_INIT procedure definition cannot return result sets.