View previous topic :: View next topic
|
Author |
Message |
Sureet Mookherjee
New User
Joined: 08 May 2009 Posts: 19 Location: India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Sureet Mookherjee
New User
Joined: 08 May 2009 Posts: 19 Location: India
|
|
|
|
Thanks dbz!! |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|