Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Where is output from PARM ABEXIT (SNA... packerm CA Products 3 Thu Sep 28, 2017 4:06 pm
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us