I have some issues accessing a Global Temporary Table created inside a COBOL-DB2 stored procedure.
The stored procedure inserts rows in this temporary table and a COBOL-CICS program accesses a cursor opened on temporary table. The issue here is --> there are 2 logical branches in Stored Procedure and for branch 1 rows are being inserted into temporary table and also being accessed properly by COBOL-CICS program. But for branch 2 --> rows are being inserted into temporary table but when COBOL-CICS program tries to access those rows it is getting SQLCODE of +100(record not found/end of cursor).
The only difference in processing done in branch 1 & 2 is that, in branch 1 couple of batch programs(Online loads of COBOL program) are being called and in branch 2 couple of online programs(Online COBOL) are being called through this stored procedure.
Initially I though the issue might have been because of some commit/syncpoint happening in called programs, so I have declared the Temporary Table with 'ON COMMIT PRESERVE ROWS'.
Can somebody suggest any possible reason for this.
The DECLARE GLOBAL TEMPORARY TABLE statement defines a temporary table for the current connection. These tables do not reside in the system catalogs and are not persistent. Temporary tables exist only during the connection that declared them and cannot be referenced outside of that connection. When the connection closes, the rows of the table are deleted, and the in-memory description of the temporary table is dropped.