GOTO statement. : GOTO « PL SQL « Oracle PL / SQL






GOTO statement.

   

SQL>
SQL> CREATE TABLE MyTable (
  2    num_col    NUMBER,
  3    char_col   VARCHAR2(60)
  4    );

Table created.

SQL>
SQL>
SQL> DECLARE
  2    v_Counter  BINARY_INTEGER := 1;
  3  BEGIN
  4    LOOP
  5      INSERT INTO MyTable
  6        VALUES (v_Counter, 'Loop count');
  7      v_Counter := v_Counter + 1;
  8      IF v_Counter >= 50 THEN
  9        GOTO l_EndOfLoop;
 10      END IF;
 11    END LOOP;
 12
 13    <<l_EndOfLoop>>
 14    INSERT INTO MyTable (char_col)
 15      VALUES ('Done!');
 16  END;
 17  /

PL/SQL procedure successfully completed.

SQL> drop table MyTable;

Table dropped.

SQL>

   
    
  








Related examples in the same category

1.Example of a proper GOTO statement
2.GOTO a Label
3.Use GoTO to jump out of a loop
4.This script demonstrates GOTO
5.Use sequential control with the GOTO statement and a block label