IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 07, 2011 2:20 pm
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: 6966
Location: porcelain throne

PostPosted: Sat May 07, 2011 2:55 pm
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
Reply with quote

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

Global Moderator


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

PostPosted: Sat May 07, 2011 5:24 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Store the data for fixed length COBOL Programming 1
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top