Your stored procedure can run as either a FENCED or a NOT FENCED stored procedure, depending on whether you register the stored procedure as FENCED or NOT FENCED in the CREATE PROCEDURE statement.
A NOT FENCED stored procedure runs in the same address space as the database manager (the DB2 Agent's address space). Running your stored procedure as NOT FENCED results in increased performance when compared with running it as FENCED because FENCED stored procedures, by default, run in a special DB2 process. The address space of this process is distinct from the DB2 System Controller.
Notes:
For debugging purposes, consider using local FENCED stored procedures. NOT FENCED and regular FENCED stored procedures complicate your debugging efforts by giving your debugger access to additional address space. Local FENCED stored procedures run in the application's address space and allow your debugger to access both the application code and the stored procedure code. To enable local FENCED stored procedures for debugging, perform the following steps:
Note: | While debugging a local FENCED stored procedure, be careful not to introduce statements that violate the restrictions listed in Restrictions. DB2 treats calls to local FENCED stored procedures as calls to a subroutine of the client application. Therefore, local FENCED stored procedures can contain statements that violate restrictions on normal stored procedures, like performing CONNECT or COMMIT statements in the procedure body. |
When you are writing a NOT FENCED stored procedure, keep in mind that it may run in a threaded environment, depending on the operating system. Thus, the stored procedure must either be completely re-entrant, or manage its static variables so that access to these variables is serialized.
NOT FENCED stored procedures must be precompiled with the WCHARTYPE NOCONVERT option. See The WCHARTYPE Precompiler Option for more information.
The following NOT FENCED stored procedures are not supported by DB2:
The following DB2 APIs and any DB2 CLI API are not supported in a NOT FENCED stored procedure: