title: Oracle error ORA-06532 when I try to populate a table that has a vararray attribute
body: <p>I am trying to populate a table that has an Vararray with data that in a table called <strong>fv_16dim</strong>.</p>
  
  <p>For doing so I am using the following code:</p>
  
  <p>Create the vararray type:</p>
  
  <pre><code>CREATE OR REPLACE TYPE fv_integer_varray AS VARRAY(16) OF INTEGER NOT NULL;
  </code></pre>
  
  <p>create the table:</p>
  
  <pre><code>CREATE TABLE cophirfv_vararray (
  id NUMBER,
  fv fv_integer_varray,
  PRIMARY KEY (id)
  );
  </code></pre>
  
  <p>Create a function that returns a vararray according to the table's ID. </p>
  
  <pre><code>CREATE OR REPLACE FUNCTION insert_VC_Array_MInteger(p_id NUMBER) 
  RETURN fv_integer_varray
  IS
       varray_integer fv_integer_varray := fv_integer_varray();
  BEGIN
      varray_integer.EXTEND(16);
  
      SELECT fv.dim1 ,
                          fv.dim2 ,
                          fv.dim3 ,
                          fv.dim4 ,
                          fv.dim5 ,
                          fv.dim6 ,
                          fv.dim7 ,
                          fv.dim8 ,
                          fv.dim9,
                          fv.dim10 ,
                          fv.dim11 ,
                          fv.dim12 ,
                          fv.dim13,
                          fv.dim14,
                          fv.dim15,
                          fv.dim16 
  INTO  varray_integer(0), varray_integer(1), varray_integer(2), varray_integer(3),
        varray_integer(4), varray_integer(5), varray_integer(6), varray_integer(7),
        varray_integer(8), varray_integer(9), varray_integer(10),
        varray_integer(11), varray_integer(12), varray_integer(13), 
        varray_integer(14), varray_integer(15)
  FROM fv_16dim fv WHERE id = p_id;
  
  RETURN varray_integer;
  
  END;
  /
  </code></pre>
  
  <p>The procedure that populates the table <strong>cophirfv_vararray</strong> </p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE populate_cophirfv_vararray
  AS
  BEGIN
      FOR i IN 1..200000 LOOP
          INSERT INTO cophirfv_vararray (id,fv) 
          SELECT i, insert_VC_Array_MInteger(i) FROM dual;
      END LOOP;
  END;
  / 
  </code></pre>
  
  <p>Then I execute the command:</p>
  
  <pre><code>EXEC populate_cophirfv_vararray;
  </code></pre>
  
  <p>But I am getting the error:</p>
  
  <pre><code>SQL&gt; EXEC populate_cophirfv_vararray;
  BEGIN populate_cophirfv_vararray; END;
  
  *
  ERRO na linha 1:
  ORA-06532: Subscript outside of limit
  ORA-06512: em "HIGIIA.INSERT_VC_ARRAY_MINTEGER", line 7
  ORA-06512: em "HIGIIA.POPULATE_COPHIRFV_VARARRAY", line 5
  ORA-06512: em line 1
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks in advance!</p>