Problem:
When passing Varchar field as Input parameter into Stored Procedure, the field contains unreadable characters and the length field of the varchar field contains some unpredictable number. Here is the example:
Input parm VARCHAR 300.
IN Cobol Program defined as:
01 LS-INPUT.
49 LS-INPUT-LEN PIC S9(4) COMP.
49 LS-INPUT-TEXT PIC X(300).
When entering value 'TESTING' from DB2 development center to run this stored procedure, on the back-end program we are getting 'TESTING......' in the LS-INPUT-TEXT, where '.....' are some unreadable values. And the LS-INPUT-LEN has some large number.
Create Procedure looks like this:
CREATE PROCEDURE FCDT040
(IN INQ_EXE_ID DEC(8,0),
IN ORDBY_COLS VARCHAR(300),
IN USER_ID CHAR(30),
OUT SQLCD INT,
OUT MSGOUT VARCHAR(100) )
DYNAMIC RESULT SETS 0
LANGUAGE COBOL
PARAMETER STYLE GENERAL WITH NULLS
NO DBINFO
FENCED
NOT THREADSAFE
MODIFIES SQL DATA
PROGRAM TYPE SUB
EXTERNAL NAME 'FCDT040!FCDT040';
Resolution:
The linkage definition of LS-INPUT-LEN needs to be defined as COMP-5. DB2 UDB will pass the value in that format. If you define the value as COMP, it will look like a very large value because of bit swapping.
#EnterpriseDeveloper
#MFDS