View previous topic :: View next topic
|
Author |
Message |
cr_aranganathan
New User
Joined: 26 Sep 2005 Posts: 3
|
|
|
|
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 |
|
|
learnmf
Active User
Joined: 14 Mar 2005 Posts: 123
|
|
|
|
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 |
|
|
krishnaiahc
New User
Joined: 31 Aug 2005 Posts: 21
|
|
|
|
Hai aranganathan,
Your right , your logic will work ...
Thanks,
Krishna |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Aranganathan,
Ur logic will work |
|
Back to top |
|
|
rtalapaneni
New User
Joined: 20 Mar 2005 Posts: 13 Location: Bangalore
|
|
|
|
I didnt get ..
Will give example code |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
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 |
|
|
paulstephen
New User
Joined: 20 Oct 2005 Posts: 20 Location: Chennai
|
|
|
|
Any number of cursors can be open at a point of time. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
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 |
|
|
paulstephen
New User
Joined: 20 Oct 2005 Posts: 20 Location: Chennai
|
|
|
|
The sequence of open and close is not a constrain. |
|
Back to top |
|
|
tam
New User
Joined: 02 Nov 2005 Posts: 12 Location: zz
|
|
|
|
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 |
|
|
|