title: How do I push items into arrays and iterate through them in PL/SQL?
body: <p>I'm trying to do something very basic in PL/SQL, but I keep getting owned... how do I push items into an array and iterate through them?</p>
  
  <p>Googling it seems to suggest using <code>owa_text.multi_line</code>;</p>
  
  <p><code>owa_text.multi_line</code> is a record of this type:</p>
  
  <pre><code>   /* A multi_line is just an abstract datatype which can hold */
     /* large amounts of text data as one piece.                 */
     type multi_line is record
     (
        rows        vc_arr,
        num_rows    integer,
        partial_row boolean
     );
  </code></pre>
  
  <p>To iterate through <code>vc_arr</code>, we have to use <code>l_array.first.. l_array.last</code>. But that gives an error while trying to access it.</p>
  
  <p>Here's a simple sample to find load distinct values into an array:</p>
  
  <pre><code>    declare
      l_persons owa_text.multi_line := owa_text.new_multi();
  /* Documentation of owa_text.new_multi(): Standard "make element" routines. */
  --function  new_multi return multi_line;
  
      l_value_exists boolean := false;
  
      cursor c_get_orders is
      select person,
               choice
      from my_orders;         
  
      begin
            for i in c_get_orders loop
                  l_value_exists := false;
                  for j in l_persons.rows.first.. l_persons.rows.last loop --Fails here, 
      --PL/SQL: numeric or value error
                            if l_persons.rows(j) = i.person then
                                  l_value_exists := true;
                                  exit;
                            end if;
                      end loop;
                      if not l_value_exists then
                            owa_text.add2multi(i.person, l_persons); 
                      end if; 
                end loop;
                for i in l_persons.rows.first.. l_persons.rows.last loop
                      write_to_log(l_persons.rows(i));
                end loop;
          end;
  </code></pre>
  
  <p>What am I missing? How do I do this?</p>
  
  <p>EDIT: Here's a script to get set up, if it helps follow the example:</p>
  
  <pre><code>create table my_orders
  (
    person  varchar2(4000 byte),
    choice  varchar2(4000 byte)
  );
  
  insert into my_orders
     (person, choice)
   values
     ('Tom', 'Juice');
  insert into my_orders
     (person, choice)
   values
     ('Jane', 'Apple');
  insert into my_orders
     (person, choice)
   values
     ('Tom', 'Cake');
  insert into my_orders
     (person, choice)
   values
     ('Jane', 'Chocolate');
  insert into my_orders
     (person, choice)
   values
     ('Tom', 'Coffee');
  commit;
  </code></pre>