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
 
Can we have a Cursor within another Cursor

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

New User


Joined: 26 Sep 2005
Posts: 3

PostPosted: Wed Sep 28, 2005 7:12 pm    Post subject: Can we have a Cursor within another Cursor
Reply with quote

CAN WE GIVE CURSOR WITH IN A CURSOR.THAT I DECLARE A CURSOR C1 ,OPEN IT AND CAN I DECLARE ANOTHER CURSOR C2 AND OPEN IT AND CLOSE C2 AND CLOSE C1.

LIKE NESTED LOOPS NESTED ,CURSORS ARE POSSIBLE OR NOT
Back to top
View user's profile Send private message

learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Wed Sep 28, 2005 7:20 pm    Post subject: Re: CURSOR WITH IN A CURSOR
Reply with quote

Hi friends
correct me if i am wrong.
It can't be possible.
Invalid sntax as open cursor commands exex sql open csr end exec.

Thanks and Regards,
Chandra
Back to top
View user's profile Send private message
krishnaiahc

New User


Joined: 31 Aug 2005
Posts: 21

PostPosted: Fri Oct 28, 2005 6:50 am    Post subject:
Reply with quote

Hai aranganathan,

Your right , your logic will work ...

Thanks,
Krishna
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Oct 28, 2005 11:21 am    Post subject:
Reply with quote

Aranganathan,

Ur logic will work
Back to top
View user's profile Send private message
rtalapaneni

New User


Joined: 20 Mar 2005
Posts: 13
Location: Bangalore

PostPosted: Fri Oct 28, 2005 12:16 pm    Post subject: Re: CURSOR WITH IN A CURSOR
Reply with quote

I didnt get ..
Will give example code
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Mon Oct 31, 2005 12:27 pm    Post subject: nested cursors
Reply with quote

hi friend,
its a difficult thing to have a nested cursors. you can open one cursor process it close it and open another one. this is the procedure
Back to top
View user's profile Send private message
paulstephen

New User


Joined: 20 Oct 2005
Posts: 20
Location: Chennai

PostPosted: Mon Oct 31, 2005 2:17 pm    Post subject:
Reply with quote

Any number of cursors can be open at a point of time.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Mon Oct 31, 2005 2:43 pm    Post subject: multiple cursor
Reply with quote

hi,
then how can the nested cursor will work. any no. of cursors can be opened and it can be closed correspondingly but overriding is not possible na.
check it out.
Eg.
Open c1
open c2

close c2
close c1
will work

open c1
open c2

close c1
close c2
won't work na.
Back to top
View user's profile Send private message
paulstephen

New User


Joined: 20 Oct 2005
Posts: 20
Location: Chennai

PostPosted: Mon Oct 31, 2005 3:12 pm    Post subject:
Reply with quote

The sequence of open and close is not a constrain.
Back to top
View user's profile Send private message
tam

New User


Joined: 02 Nov 2005
Posts: 12
Location: zz

PostPosted: Thu Nov 03, 2005 11:56 am    Post subject:
Reply with quote

though nested cursors can be used in db2 - COBOL program but it affects the program efficiency. there are 3 main steps involved in a cursor - open, fetch and close. out of these the open step requires the maximum overhead and nesting of cursors means that you're opening the inner cursor multiple times for every new records fetched by the outer cursor while the outer cursor is still opened. the more efficient way than using the nested cursors is fetch the records of the outer cursor in an array and execute the inner cursor for every record in the array. thus we can save the overhead of opening 2 cursors simultaneously.
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 -502 Error - Cursor already open anand jeyapaul DB2 7 Sun Oct 29, 2017 4:22 am
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
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
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm

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