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
 

 

How to store the output of an cursor into an array in Cobol

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

New User


Joined: 08 May 2009
Posts: 19
Location: India

PostPosted: Sat May 07, 2011 2:06 pm    Post subject: How to store the output of an cursor into an array in Cobol
Reply with quote

I have a cursor joining two tables after a successful fetch I need to store the output of this cursor into a Ws-Array and then read each record from the array and identify a particular member with some specific information
I am looking for

How can I achieve this?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat May 07, 2011 2:20 pm    Post subject: Reply to: How to store the output of an cursor into an array
Reply with quote

Approximately as you described it.

You confuse things by using "read" and "member" when talking about the "array", so depending on how you use these words you could be a long way off.

Consult the manuals, have a go at it, and let us know if you still have problems.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sat May 07, 2011 2:55 pm    Post subject:
Reply with quote

it is rather well documented in the db2 manuals.

using rowset fetch into a host-array and then processing the array is rather simple,
although it requires a secondary loop.
single row fetch has a loop around the fetch statement.
rowset fetch is an outer loop around the fetch
and an inner loop around the host-array.
the counter being sqlrrcd(3) - (spelling look-up the exact spelling for the sqlca field)
as with any loop, you have
  • beginning of loop logic
  • middle of loop logic
  • end of loop logic

FETCH rowset
sqlcode <> 0 close cursor/continue
sqlcode < 0 dsntiar/goto eoj
sqlrrcd(3) > 0 process host-array/contine
sqlcode = 0 goto Fetch
EOJ
Back to top
View user's profile Send private message
Sureet Mookherjee

New User


Joined: 08 May 2009
Posts: 19
Location: India

PostPosted: Sat May 07, 2011 3:07 pm    Post subject:
Reply with quote

Thanks dbz!!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sat May 07, 2011 5:24 pm    Post subject:
Reply with quote

you are welcome.

you should also acquaint yourself with 'GET DIAGNOSTICS',
that will provide you info for each row retrieved.

personnally, I only use it when there are 'odd' sqlcodes or i have a problem with truncation. (but the null-indicator variable for a column provides that info, also).

the only odd issues that I have encountered with ROWSET retrieval concern var-char columns with update or insert - and the only issue is the proper db2 syntax. if you have problems, open a new thread on the board, and someone will be able to provide guideance/help.
have a good weekend.
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts JES2 doesn't honor the priority of th... Aron Lendvai JCL & VSAM 7 Thu Jun 29, 2017 1:41 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


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