title: How to add values to a VARRAY using a loop
body: <p>I have a VARRAY and I want to add elements to this VARRAY by using a loop. This is what I have tried so far.</p>
  
  <pre><code>DECLARE
  TYPE code_array_  IS VARRAY(26) OF VARCHAR2(6);
  codes_ code_array_;
  
  BEGIN
  FOR i IN 1..26 LOOP    
      codes_(i) := dbms_random.string('U',6);
    END LOOP;
  END;
  </code></pre>
  
  <p>Above code gives me an error</p>
  
  <blockquote>
    <p>"ORA-06531: Reference to uninitialized collection"</p>
  </blockquote>