Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Statements
 

Count up by hundreds until we get an error

SQL> SQL> SET ECHO ON SQL> SET SERVEROUTPUT ON SQL> SQL> DECLARE   2    hundreds_counter  NUMBER(1,-2);   3  BEGIN   4    hundreds_counter := 100;   5    LOOP   6      DBMS_OUTPUT.PUT_LINE(hundreds_counter);   7      hundreds_counter := hundreds_counter + 100;   8    END LOOP;   9  EXCEPTION  10  WHEN OTHERS THEN  11    DBMS_OUTPUT.PUT_LINE('Done.');  12  END;  13  / 100 200 300 400 500 600 700 800 900 Done. PL/SQL procedure successfully completed. SQL>