467,894 Members | 1,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,894 developers. It's quick & easy.

CREATE FUNCTION with COBOL doesn't work!!

We have z/os and DB/2 V. 8 running. I try to create a new UDF using the command CREATE FUNCTION:
CREATE FUNCTION CNGETADR (INTEGER)
RETURNS CHAR(50)
EXTERNAL NAME CNADR001
PARAMETER STYLE DB2SQL
WLM ENVIRONMENT WLMENV
LANGUAGE COBOL
DETERMINISTIC
NO SQL
NO DBINFO
NO EXTERNAL ACTION

This was OK (return code 0).

How exactly is the parameter passed to the COBOL-Programme CNADR001? I found two different manuals both from IBM:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/r0009191.htm
and
ftp://ftp.software.ibm.com/ps/products/db2/info/xplatsql/pdf/en_US/cpsqlrv2.pdf (see Appendix L).
The information in the manuals differs in the sizes of some the the parameters that are passed to COBOL.

My COBOL-Programme CNADR001 I tried both ways:
1)

********************************
LINKAGE SECTION.
********************************
*
01 PARAM-LIST.
05 PARAM-IN PIC S9(9) BINARY.
05 PARAM-OUT PIC X(50).
05 PARAM-IN-IND PIC S9(4) BINARY.
05 PARAM-OUT-IND PIC S9(4) BINARY.
05 PARAM-SQLSTATE PIC X(05).
05 PARAM-QUAL-F-N.
10 PARAM-QFN-LEN PIC S9(4) COMP.
10 PARAM-QFN-DATA PIC X(257).
05 PARAM-SPEC-NAME.
10 PARAM-SN-LEN PIC S9(4) COMP.
10 PARAM-SN-DATA PIC X(18).
05 PARAM-DIAGNOS.
10 PARAM-DIA-LEN PIC S9(4) COMP.
10 PARAM-DIA-DATA PIC X(70).
*
01 PARAM-RUECK.
05 PARAM-OUT-DATA PIC X(50).

*********************************
PROCEDURE DIVISION USING PARAM-LIST
RETURNING PARAM-OUT-DATA.
...

2)

********************************
LINKAGE SECTION.
********************************
*
01 PARAM-LIST.
05 PARAM-IN PIC S9(9) BINARY.
05 PARAM-OUT PIC X(50).
05 PARAM-IN-IND PIC S9(9) BINARY.
05 PARAM-OUT-IND PIC S9(9) BINARY.
05 PARAM-SQLSTATE PIC X(05).
05 PARAM-QUAL-F-N.
10 PARAM-QFN-LEN PIC S9(4) COMP.
10 PARAM-QFN-DATA PIC X(517).
05 PARAM-SPEC-NAME.
10 PARAM-SN-LEN PIC S9(4) COMP.
10 PARAM-SN-DATA PIC X(128).
05 PARAM-DIAGNOS.
10 PARAM-DIA-LEN PIC S9(4) COMP.
10 PARAM-DIA-DATA PIC X(70).
*
01 PARAM-RUECK.
05 PARAM-OUT-DATA PIC X(50).

*********************************
PROCEDURE DIVISION USING PARAM-LIST
RETURNING PARAM-OUT-DATA.

However, when I use the new function with
SELECT CNGETADR(1)
FROM SYSIBM.SYSDUMMY1;
I get
SQLCODE = -450, ERROR: USER-DEFINED FUNCTION OR STORED PROCEDURE
CNGETADR, PARAMETER NUMBER 1, OVERLAYED STORAGE BEYOND ITS DECLARED
LENGTH
SQLSTATE = 39501 SQLSTATE RETURN CODE

Can anybody tell me what I did wrong?

TIA
Sep 1 '06 #1
  • viewed: 2988
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Savas Ates | last post: by
1 post views Thread by Hugo Flores | last post: by
reply views Thread by bog39 | last post: by
2 posts views Thread by effendi | last post: by
reply views Thread by Juna | last post: by
Thew
2 posts views Thread by Thew | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.