View previous topic :: View next topic
|
Author |
Message |
cdhami
New User
Joined: 24 Jan 2006 Posts: 28
|
|
|
|
Hi all,
I have a program where i retreive a IMS record and declare cursor then open cursor and then continue retreiving next IMS record.
problem here is i forgot to close the cursor, still i am not getting -502 abend since i do open multiple times without closing it.
does anybody knows why this is happening
is it because of declare used just before open cursor causing the cursor to get reset.???
Let me know ..
Thanks
Cdhami |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Cdhami,
Can you show us your code...
Sushanth |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Cdhami,
Declare cursor is not an executable DB2 statement.
I am not IMS expert but did you code IMS checkpoint command that is executed before coming to open cursor command again?
We may be missing something here.
As requested earlier, it will be best if you could paste your code removing any site specific information that you may have. |
|
Back to top |
|
|
cdhami
New User
Joined: 24 Jan 2006 Posts: 28
|
|
|
|
Here is my code snippet
PERFORM 2000-PROCESS-IMSQ
UNTIL STATUS-CODE IN IO-PCB = 'QC'
2000-PROCESS-IMSQ
Read IMSQ
IF STATUS-CODE IN IO-PCB IS EQUAL TO SPACES
Perform 2251-DECL-POSTING-CS
EXEC SQL
DECLARE TLA-POSTING CURSOR WITH HOLD FOR
SELECT DISTINCT POST_VALUE_DATE
FROM TLA_POSTDATA
WHERE ACCT_SWIFT_ADDR
=:DCLTLA-POSTDATA.ACCT-SWIFT-ADDR
ORDER BY POST_VALUE_DATE ASC
FETCH FIRST 5 ROWS ONLY
END-EXEC.
EXEC SQL
OPEN TLA-POSTING
END-EXEC.
PERFORM 2252-FETCH-PRCS-POSTING
UNTIL FORWARD-DT-NOT or no-record-found
2252-FETCH-PRCS-POSTING.
EXEC SQL
FETCH TLA-POSTING
INTO :DCLTLA-POSTDATA.POST-VALUE-DATE
END-EXEC.
do processing
End of code
As above,
Para 2000-PROCESS-IMSQ is executed multiple times, the declare is inside this. There is no closing of cursor. since no closing of cursor is done, the cursor is still open when processing next record.
when i process multiple records then also program doesn't abend
whereas in other code, i receive -502 error code where cursor is not closed.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you look at the expanded cobol code. The declare is only done once, not each time thru the code. What causes you to believe the declare is actually executed multiple times?
I suspect there is some other misunderstanding or that there is a bit of code that makes a difference that has not been posted. Please do not post the entire program as it is too big for this. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
cdhami wrote: |
whereas in other code, i receive -502 error code where cursor is not closed. |
I did not go through the entire thread yet and did not look into your code much - however, does the other code also has "WITH HOLD" in cursor declaration? A holdable cursor is kept open over COMMIT and closed upon ROLLBACK. |
|
Back to top |
|
|
|