Use sequential control with the GOTO statement and a block label : GOTO « PL SQL « Oracle PL / SQL






Use sequential control with the GOTO statement and a block label

    
SQL>
SQL> DECLARE
  2    counter NUMBER := 1;
  3  BEGIN
  4    WHILE (counter < 5) LOOP
  5      IF counter = 2 THEN
  6        GOTO loopindex;
  7      ELSE
  8        dbms_output.put_line('Index ['||counter||'].');
  9      END IF;
 10      << loopindex >>
 11      IF counter >= 1 THEN
 12        counter := counter + 1;
 13      END IF;
 14    END LOOP;
 15  END;
 16  /
Index [1].
Index [3].
Index [4].

PL/SQL procedure successfully completed.

   
    
    
    
  








Related examples in the same category

1.GOTO statement.
2.Example of a proper GOTO statement
3.GOTO a Label
4.Use GoTO to jump out of a loop
5.This script demonstrates GOTO