Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Will a called DB2 routine close the cursor automatically?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Dec 11, 2006 6:55 pm    Post subject: Will a called DB2 routine close the cursor automatically?
Reply with quote

Hi

Program A calls program B. A is a non-DB2 program and B is a DB2 one.
A will call B in a loop. I open a cursor in the pgm B and suppose say it fetches 50 recs, then pgm A will call pgm B 50 times to give back each one record. Now my Q is, will the cursor be closed when it goes back to A every time ?

or Is there any other any solution to transfer all the records to pgm A that are fetched in pgm B. Here we will not be knowing how many records will be fetched from the cursor?

Thanks & Regards
Prabs
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 6:59 pm    Post subject:
Reply with quote

Just guessing, but unless B closes the cursor, the second visit should still be part of the same LUW. Of course, some of the types of call can wreak havic on that. icon_eek.gif
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Dec 11, 2006 7:04 pm    Post subject: Re: Will a called DB2 routine close the cursor automatically
Reply with quote

What is LUW?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 7:07 pm    Post subject:
Reply with quote

Logical unit of work
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Dec 11, 2006 7:19 pm    Post subject:
Reply with quote

Not too sure. DB2 experts any take on this?
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Dec 11, 2006 9:05 pm    Post subject: Re: Will a called DB2 routine close the cursor automatically
Reply with quote

Agree with William.

- A Cursor has to be explicitly closed.
- If a commit is issued and cursor has not being declared WITH HOLD, cursort gets closed.

Also you say 'Cursor is opened in Pgm B', so next call when A calls B, probably it is calling with different parameters otherwise B will give you error 'Cursor already opened'.

To transfer more than record to PGM A, you can declare a linkage area copybook with Occurs ( give a reasonable limit, say 20) and populate occurs in a FETCH/LOOP. You will have to code cursor SQL so that next time program A call B incase there are more than 20 rows then SQL starts with 21 row.
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 How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts SORT - E15 and E35 using same user ex... Abhi Nature DFSORT/ICETOOL 12 Mon Oct 03, 2016 4:33 pm
This topic is locked: you cannot edit posts or make replies. How to supply called sub-program from... dchristensen JCL & VSAM 25 Wed Sep 14, 2016 11:36 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us