By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,233 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,233 IT Pros & Developers. It's quick & easy.

CREATE FUNCTION with COBOL doesn't work!!

P: n/a
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/infoce...d/r0009191.htm
and
ftp://ftp.software.ibm.com/ps/produc...S/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?

Sep 1 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.