DB2 External function using COBOL language

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
Db2hero
Member
Posts: 6
Joined: Fri Apr 10, 2009 9:04 am

DB2 External function using COBOL language

Post by Db2hero » Thu Apr 16, 2009 3:05 am

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.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Apr 16, 2009 6:24 pm

Hi,

So far you did not get any reply(ies) because your question, I believe, is not well understood. Suggest you reframe your question and post us back - some one will be around . . .
Regards,
Anuj

Db2hero
Member
Posts: 6
Joined: Fri Apr 10, 2009 9:04 am

Post by Db2hero » Thu Apr 16, 2009 11:21 pm

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.

Db2hero
Member
Posts: 6
Joined: Fri Apr 10, 2009 9:04 am

Post by Db2hero » Thu Apr 16, 2009 11:23 pm

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;

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Apr 17, 2009 10:02 am

Hi,

Please check this link: http://publib.boulder.ibm.com/infocente ... 009191.htm

I do not have much experience with UDF . . . :oops:
Last edited by Anuj Dhawan on Fri Apr 17, 2009 3:02 pm, edited 1 time in total.
Regards,
Anuj

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Apr 17, 2009 1:50 pm

Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Post Reply

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



Other References
Mainframe Tools and others