Are nested cursors possible in DB2?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vandhana
    New Member
    • Feb 2011
    • 3

    Are nested cursors possible in DB2?

    Is something like this possible ? I guess not...since I get an error due to the while statement within a cursor block. Each of the cursor block individually runs fine.

    Code:
    declare c1
    open c1
    fetch from c1 into
    while (SQLSTATE = '00000') do
       declare c2
       open c2
       fetch from c2 into
       while (SQLSTATE = '00000') do
       any OPERTATION
       fetch from c2
       end while
       close c2
    fetch from c1
    end while
    close c1
    Last edited by Niheel; Feb 5 '11, 06:18 PM.
  • Vandhana
    New Member
    • Feb 2011
    • 3

    #2
    Yes it works. Except that the the declaration of the second cursor c2 should be right on top. :)

    Comment

    Working...