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
 
open cursor getting executed multiple times without error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: open cursor getting executed multiple times without error
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: 1013
Location: India

PostPosted: Fri Apr 23, 2010 9:38 pm    Post subject:
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: 686
Location: Earth

PostPosted: Fri Apr 23, 2010 11:45 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Apr 26, 2010 12:44 pm    Post subject:
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

Senior Member


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

PostPosted: Mon Apr 26, 2010 9:37 pm    Post subject:
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    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 Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Formatting multiple records to a sing... Vignesh Sid SYNCSORT 3 Tue Nov 07, 2017 12:22 pm
No new posts Updating multiple counts in trailer!! Vignesh Sid SYNCSORT 4 Mon Nov 06, 2017 1:04 pm
No new posts -502 Error - Cursor already open anand jeyapaul DB2 7 Sun Oct 29, 2017 4:22 am
No new posts Selecting a row from multiple tables! Vignesh Sid DB2 2 Thu Oct 26, 2017 6:09 pm

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