Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003

    Unanswered: Skipping to a next interation in a FOR LOOP


    I'm trying to write a bit of plsql code which enters a FOR LOOP, checks if a condition is true, and if it is then jumps an interation in the loop and does not execute the rest of the code in the current iteration. I could just contain the rest of the code in the ELSE clause of the IF statement, but would rather try to jump to the next iteration if possible instead.

    Any ideas? A sample of the code is below.


    FOR i IN 1..io_NodeRouteTable.COUNT LOOP
    IF io_NodeTable(i).NodeID = io_NodeTable(i+2).NodeID then
    i := i+1
    [jump to the next iteration];
    END IF;
    [loads more code I'd rather not put into an ELSE statement]

  2. #2
    Join Date
    Nov 2003
    down on the cube farm, left then right then another left
    There is no such thing as a BREAK command in PLSQL (why I do not now). There is the GOTO (aaack, aack, [choking sounds continue]). Because of my 20 years of C experience I rarely ever think of that option. Truthfully though a BREAK is nothing but a specific purpose GOTO. I used to use the if-else method but it can easily become cumbersome. I would suggest the GOTO but will add the admonishment to never use GOTO elsewhere. Check the PL/SQL reference guide for specifics
    NOTE: Please disregard the label "Senior Member".

Posting Permissions

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