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
 
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts LIBDEF not working in called proc packerm CLIST & REXX 0 Fri Sep 15, 2017 7:22 pm
No new posts Could we identify the called modules ... elixir1986 COBOL Programming 5 Fri Jul 14, 2017 1:53 am
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am

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