Mega Code Archive

 
Categories / Oracle PLSQL / PL SQL
 

Define a varray with a three element constructor of null elements and attempt to populate it beyond three elements

SQL> SQL> SET ECHO ON SQL> SET SERVEROUTPUT ON SIZE 1000000 SQL> SQL> SQL> CREATE OR REPLACE TYPE integer_varray   2    AS VARRAY(3) OF INTEGER;   3  / Type created. SQL> SQL> DECLARE   2   3       4    intArray INTEGER_VARRAY := integer_varray(NULL,NULL,NULL);   5   6  BEGIN   7   8    FOR i IN 1..3 LOOP   9  10      intArray(i) := 10 + i;  11  12    END LOOP;  13  14  15      16    FOR i IN 1..3 LOOP  17  18      dbms_output.put     ('Integer Varray ['||i||'] ');  19      dbms_output.put_line('['||intArray(i)||']');  20  21    END LOOP;  22  23  END;  24  / Integer Varray [1] [11] Integer Varray [2] [12] Integer Varray [3] [13] PL/SQL procedure successfully completed. SQL>