An external procedure can be dynamically fetched or released by a program. This means that it can be loaded or deleted by the program using the FETCH and RELEASE statements. When the procedure is not in main storage, it can be loaded into it and then deleted from it at any time during the execution of the calling procedure. This is useful when it is not necessary to call the external procedure every time when the calling procedure is executed.
A procedure has to be loaded into main storage before it can be executed, unless it is already there. Once loaded, the procedure can remain in main storage until the execution of the whole program is completed, or it can be deleted at any time using the RELEASE statement.
A fetched procedure is compiled and linked separately from the calling procedure. For more information, see Compiling, Linking and Debugging of Fetchable Procedures.
Whenever the load module containing the fetched procedure is loaded into memory, the STATIC variables in the fetched procedure are given the initial values indicated by their declarations.
Note that EXTERNAL files and CONDITION conditions are shared across the whole application, including the fetched procedures.