Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2014
    Posts
    294

    Unanswered: Multiple cursors Infinite loop

    Hi,

    I have written one procedure . every thing is working fine. But My first loop is entering into infinite loop. I tried to resolve this but unable to get .sorry for posting my code. I am missing something here .
    can some one kindly help me out.



    CREATE PROCEDURE proc1 ()
    DYNAMIC RESULT SETS 5
    P1: BEGIN






    error:

    wloop1 Infinite loop. can some one tell me how to exit from the first loop.


    Thanks
    Last edited by HABBIE; 11-13-14 at 03:53.

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    Tell us what exactly is happening at the second loop - you are getting the same row as at the first loop or what?
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    Code:
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET exitcode = 1;
    
    ...
    wloop1:
    WHILE (SQLCODE = 0)
    DO
    ...
    FETCH ...;
    -- due to CONTINUE HANDLER your SQLCODE becomes equal to 0 here always
    -- because setting the exitcode variable to 1 in the handler returns SQLCODE=0
    END WHILE;
    the workaround may look like this:

    Code:
    wloop1:
    WHILE (exitcode = 0)
    DO
    ...
    set exitcode=0;
    FETCH ...;
    END WHILE;
    Regards,
    Mark.

  4. #4
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    @mark.b
    It was my first impression too. But it has a LEAVE there that should work
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  5. #5
    Join Date
    Jul 2014
    Posts
    294
    Thanks Mark. Helped a lot

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •