Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 Table UDF in COBOL or PL/1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
shivani_jha

New User


Joined: 12 Feb 2007
Posts: 11
Location: mumbai

PostPosted: Mon Mar 17, 2008 2:14 pm    Post subject: DB2 Table UDF in COBOL or PL/1
Reply with quote

Hi, I am writing a DB2 user defined function which returns a table of 2 columns.

I wan to know how can i return a table in PL/1 or COBOL. Can anybody has a sample code which i can refer for my requirement?

Regards,
Shivani
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Mar 17, 2008 5:01 pm    Post subject:
Reply with quote

Hello,

Please explain your requirement in more detail.

If the function creates a 2-column table, why can the pl/i or cobol code not simply read the table?

I suspect that i am missing something.
Back to top
View user's profile Send private message
shivani_jha

New User


Joined: 12 Feb 2007
Posts: 11
Location: mumbai

PostPosted: Mon Mar 17, 2008 5:38 pm    Post subject:
Reply with quote

Hi Following is the function for which I want code in the host language (COBOL or PL/1)

CREATE FUNCTION GAME_RESULTS(INTEGER)
RETURNS TABLE (WEEK INTEGER,
WINNER CHAR(20),
WINNER_SCORE INTEGER,
LOSER CHAR(20),
LOSER_SCORE INTEGER)
EXTERNAL NAME GAMES
LANGUAGE COBOL
PARAMETER STYLE DB2SQL
NO SQL
DETERMINISTIC
NO EXTERNAL ACTION
FENCED
SCRATCHPAD
FINAL CALL
DISALLOW PARALLEL
CARDINALITY 300;

I hope it helps...Please let me know if you want more information.
Back to top
View user's profile Send private message
anv2005

New User


Joined: 14 Jul 2005
Posts: 44
Location: US

PostPosted: Tue Mar 18, 2008 1:15 am    Post subject: Reply to: DB2 Table UDF in COBOL or PL/1
Reply with quote

Can't you DECLARE cursor:

EXEC SQL DECLARE MYCSR CURSOR FOR
SELECT WEEK, WINNER, ... FROM TABLE (GAME_RESULTS(<integer>))
END-EXEC.
Back to top
View user's profile Send private message
shivani_jha

New User


Joined: 12 Feb 2007
Posts: 11
Location: mumbai

PostPosted: Tue Mar 18, 2008 9:53 am    Post subject:
Reply with quote

No I can not declare cursor......as the approach taken for this project is to write UDF....and this is just an example there are so many functions that we need to write in this way.

I have verified that this is possible as per the information available on Internet but could not find any example for this.
Back to top
View user's profile Send private message
anv2005

New User


Joined: 14 Jul 2005
Posts: 44
Location: US

PostPosted: Tue Mar 18, 2008 10:15 am    Post subject: Reply to: DB2 Table UDF in COBOL or PL/1
Reply with quote

The DECLARE CURSOR is used to invoke UDF within the COBOL or PL/I program. Then, FETCH the rows from the TABLE as returned by your UDF.
Back to top
View user's profile Send private message
shivani_jha

New User


Joined: 12 Feb 2007
Posts: 11
Location: mumbai

PostPosted: Tue Mar 18, 2008 11:47 am    Post subject:
Reply with quote

Thanks for the info.

Suppose I am using SELECT WHETHER,CITY FROM UDF_FUNCTION(AA);

and this UDF_FUNCTION is returning more than one row then what should be returned from the PL/1 program or COBOL program....is it a array for all the columns or just one occurence for those fields.....
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us