Control Flow in PL/SQL (Cont.)


At least one of the statements in <loop_body> should be an EXIT statement of the form
   EXIT WHEN <condition>;
The LOOP breaks if <condition> is true. For example, one way to insert each of the pairs (1, 1) through (10, 10) into T1 of the above two examples is

DECLARE
  i  NUMBER := 1;
BEGIN
  LOOP
    INSERT INTO  T1  VALUES(i, i);
    i := i + 1;
    EXIT WHEN  i > 10;
  END LOOP;
END;
/

Some other useful loop-forming statements are:


      β€œIt is not that I’m so smart. But I stay with the questions much longer.”    
      ― Albert Einstein