Hi.
I'm trying to create an external function with COBOL as the host language.
How do I pass the data from COBOL back to DB2? The function returns a TIMESTAMP value.
THANKS.
DB2 External function using COBOL language
Moderators: dbzTHEdinosauer, Moderator Group
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
I created a DB2 external function like:
CREATE FUNCTION NTEST1 (TIMESTAMP)
RETURNS SMALLINT
EXTERNAL NAME ?NTESTMOD?
SPECIFIC MINENULL1
LANGUAGE COBOL
DETERMINISTIC
NO SQL
FENCED
PARAMETER STYLE SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION;
COBOL is the language to implement the function. I tried using the LINKAGE SECTION to pass the output parameter which in this case should be a timestamp but when I call the function nothing is returned. But when I run the COBOL program as stand alone the program works fine.
For stored procedures the linkage section works fine in passing paramters but when used as an external function it doesn't. I'm not sure what I'm missing and now I'm stuck and out of ideas.
I hope I'm explaining it clearer this time and I hope nobody in the forum mind my question since it crosses DB2 and COBOL.
CREATE FUNCTION NTEST1 (TIMESTAMP)
RETURNS SMALLINT
EXTERNAL NAME ?NTESTMOD?
SPECIFIC MINENULL1
LANGUAGE COBOL
DETERMINISTIC
NO SQL
FENCED
PARAMETER STYLE SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION;
COBOL is the language to implement the function. I tried using the LINKAGE SECTION to pass the output parameter which in this case should be a timestamp but when I call the function nothing is returned. But when I run the COBOL program as stand alone the program works fine.
For stored procedures the linkage section works fine in passing paramters but when used as an external function it doesn't. I'm not sure what I'm missing and now I'm stuck and out of ideas.
I hope I'm explaining it clearer this time and I hope nobody in the forum mind my question since it crosses DB2 and COBOL.
Sorry the CREATE FUNCTION should look like this
CREATE FUNCTION NTEST1 (TIMESTAMP)
RETURNS TIMESTAMP <-------------- should be timestamp not smallint
EXTERNAL NAME ?NTESTMOD?
SPECIFIC MINENULL1
LANGUAGE COBOL
DETERMINISTIC
NO SQL
FENCED
PARAMETER STYLE SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION;
CREATE FUNCTION NTEST1 (TIMESTAMP)
RETURNS TIMESTAMP <-------------- should be timestamp not smallint
EXTERNAL NAME ?NTESTMOD?
SPECIFIC MINENULL1
LANGUAGE COBOL
DETERMINISTIC
NO SQL
FENCED
PARAMETER STYLE SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION;
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
Hi,
Please check this link: http://publib.boulder.ibm.com/infocente ... 009191.htm
I do not have much experience with UDF . . .
Please check this link: http://publib.boulder.ibm.com/infocente ... 009191.htm
I do not have much experience with UDF . . .
Last edited by Anuj Dhawan on Fri Apr 17, 2009 3:02 pm, edited 1 time in total.
Regards,
Anuj
Anuj
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page