DEV Community

kim
kim

Posted on

PL/SQL Cheat Sheet

Below is PL/SQL - Loops Cheat Sheet:

Basic Loop

LOOP 
   The sequence of statements; 
END LOOP; 

WHILE Loop

WHILE condition LOOP 
   sequence_of_statements 
END LOOP; 

FOR Loop

FOR counter IN initial_value .. final_value LOOP 
   sequence_of_statements; 
END LOOP;

Nested Loops

  • Nested basic LOOP
LOOP 
   Sequence of statements1 
   LOOP 
      Sequence of statements2 
   END LOOP; 
END LOOP;
  • Nested FOR LOOP
FOR counter1 IN initial_value1 .. final_value1 LOOP 
   sequence_of_statements1 
   FOR counter2 IN initial_value2 .. final_value2 LOOP 
      sequence_of_statements2 
   END LOOP; 
END LOOP;
  • Nested WHILE LOOP
WHILE condition1 LOOP 
   sequence_of_statements1 
   WHILE condition2 LOOP 
      sequence_of_statements2 
   END LOOP; 
END LOOP; 

EXIT statement

EXIT;
CONTINUE statement
CONTINUE;

GOTO statement

GOTO label;
..
..
<< label >>
statement;

...
Full cheat sheet is here

Top comments (0)