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

open cursor getting executed multiple times without error


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cdhami

New User


Joined: 24 Jan 2006
Posts: 28

PostPosted: Fri Apr 23, 2010 8:05 pm
Reply with quote

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
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Apr 23, 2010 9:38 pm
Reply with quote

Cdhami,

Can you show us your code...

Sushanth
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Apr 23, 2010 11:45 pm
Reply with quote

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
View user's profile Send private message
cdhami

New User


Joined: 24 Jan 2006
Posts: 28

PostPosted: Mon Apr 26, 2010 12:30 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Apr 26, 2010 12:44 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Apr 26, 2010 9:37 pm
Reply with quote

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
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 RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Error to read log with rexx CLIST & REXX 11
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Error when install DB2 DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top