EXIT WHEN clause. : EXIT « PL SQL « Oracle PL / SQL






EXIT WHEN clause.

  
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 index');
  7      v_Counter := v_Counter + 1;
  8      EXIT WHEN v_Counter > 50;
  9    END LOOP;
 10  END;
 11  /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> drop table MyTable;

Table dropped.

SQL>

   
  








Related examples in the same category

1.Impact of EXIT in a function
2.Using EXIT with a simple LOOP
3.Using EXIT with a WHILE loop
4.Using EXIT with a FOR loop
5.Unconstrained loop: exit
6.Exit outer loop with 'EXIT LabelName When' statement
7.Exit to a label
8.Exit loop since last index value is read.