Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

COBOL DB2 PROCEDURE

$
0
0

I am new to COBOL language. After I studied through the tutorials with Visual COBOL.  I tried to write my first DB2 stored procedure.

This is my environment setup:

Windows 10 Enterprise Edition.    I installed DB2 10.5 Express Edition , Visual Studio 2015 Enterprise Edition, Visual COBOL 2.3  personal edition.

I compile the following code as Library Project, output as DB2PROC.dll

       identification division.
       program-id. DB2PROC.

       environment division.
       configuration section.

       data division.
       
       linkage section.
       01 INPARAM      PIC X(20).                 
       01 OUTPARAM  PIC X(80).

       procedure division USING INPARAM
                                                      OUTPARAM.
       string INPARAM delimited by spaces  
              ' COBOL WORLD!!!'delimited by space  into OUTPARAM
           goback.
       end program DB2PROC.


I copied DB2PROC.dll into IBM\SQLLIB\FUNCTION  folder, I also copied COBOL run-time library  cblrtsm.dll in the same folder.

Then I created DB2 stored procedure:

CREATE PROCEDURE DB2PROC
(IN INPARAM CHAR(20), OUT OUTPARAM  CHAR(80))
RESULT SETS 0
MODIFIES SQL DATA
LANGUAGE COBOL
EXTERNAL NAME  'C:\Program Files\IBM\SQLLIB\FUNCTION\DB2PROC.dll'
FENCED
NOT THREADSAFE
NO DBINFO
PROGRAM TYPE SUB
PARAMETER STYLE GENERAL;

From  IBM data studio, when I call that procedure, it gives me error:

[jcc][t4][1065][12306][3.68.61] Caught java.io.CharConversionException.  See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null
Run of routine failed.
 - Roll back completed successfully.

But if I change the 2nd parameter as INOUT

CREATE PROCEDURE DB2PROC
(IN INPARAM CHAR(20), INOUT OUTPARAM  CHAR(80))

The error is gone,  I can run it successfully.  but OUTPARAM does not return anything to me.

Could someone help me to point out what is wrong with my code?

Really appreciated.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>