It is possible to debug PL/I DB2 LUW Stored Procedures but care should be used when doing this. It is not recommended that production DB2 LUW servers be used because of the impact on processing and potential security issues. Using a VM image to debug the stored procedure is one option or using a single user version of the software like DB2 Express-C on a development workstation is another option.
Do the following before attempting to debug stored procedures:
CREATE PROCEDURE GETPRML (IN PROCNM CHAR(18) ,IN SCHEMA CHAR(8) ,INOUT OUTCODE INTEGER ,INOUT PARMLST CHAR(26) ) LANGUAGE COBOL DETERMINISTIC READS SQL DATA NO DBINFO FENCED NOT THREADSAFE EXTERNAL NAME "GETPRML!GETPRML" PARAMETER STYLE GENERAL PROGRAM TYPE SUB RESULT SETS 0;
PROC(PROCNM, SCHEMA, OUTCODE, PARMLST); /* EXTERNAL('getprml'); */
mfplx -sql db2 -optsql db=sample -deb -coffdebug -defext getprml.pli -c –ppsql
SET LINK=-DEBUG
cbllink /d /V /K getprml.obj db2api.lib mfplimd.lib systemsql.obj setupdeffiles.obj
set CODEWATCH_SRCPATH=C:\Program Files\IBM\SQLLIB\FUNCTION
set CODEWATCH_STBPATH=C:\Program Files\IBM\SQLLIB\FUNCTION
It is easier to find if you have 64-bit version of DB2 LUW installed since it is a 32-bit version.
One tool that you could use is PSLIST which is available from www.sysinternals.com under PsTools download. The command to execute is:
PSLIST DB2FMP
The results would look something like this using 64-bit DB2 LUW:
Name Pid Pri Thd Hnd Priv CPU Time Elapsed Time db2fmp64 2240 8 9 211 16660 0:00:00.655 0:00:50.512 db2fmp64 2240 8 9 211 16660 0:00:00.655 0:00:50.512 db2fmp64 2056 8 4 143 10888 0:00:00.046 0:00:15.241 db2fmp 2528 8 3 117 12172 0:00:00.140 0:00:15.163
If more than one PID for db2fmp is listed, try them one at a time to determine which one is the stored procedure you want to debug. You could also use CTF trace to determine which PID is being used.
java –jar <installation path>/cw_java.jar –pid 2528
The CodeWatch window appears.
You can now perform debugging tasks including evaluating variables and stepping through code. When you return, the results of the stored procedure call are available to the calling process.