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

Will a called DB2 routine close the cursor automatically?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 6:59 pm
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
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: 3156
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 7:07 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Is there a way to close VSAM files us... CICS 8
No new posts step by step trace 4 ISPF dialog call... TSO/ISPF 17
No new posts ACS exit routine JCL & VSAM 0
No new posts Routine not found... CLIST & REXX 6
No new posts Get name of Subsystem routine is exec... All Other Mainframe Topics 2
Search our Forums:

Back to Top