title: Receiving ORA-06531 Reference to uninitialized collection error
body: <p>I am running a function that imports a file and I am receiving the following Oracle error:</p>
  
  <p>ORA-06531: Reference to uninitialized collection
  ORA-06512: at "BANINST1.SZKPERT", line 186</p>
  
  <p>I have read on other answers that I need to initialize a collection to avoid this error.  However, I am unsure what collection I need to initialize and what syntax should I use.  Below is the function:</p>
  
  <pre><code>function f_get_pert_examinees (p_filename varchar2)
  return baninst1.scf_pert_test_examinee_nt
  pipelined 
  is
  lv_filename     CONSTANT varchar2(50) := p_filename;
  
  lv_examinee_tab lt_download_tab_type;
  lv_remote_data  clob;
  lv_char         varchar2(1);
  lv_eol          boolean := false;
  lv_tablen       binary_integer;
  lv_list         szkftpx.t_string_table;
  type lt_field_tab_type is table of varchar2(50) index by binary_integer;
  lv_field_tab    lt_field_tab_type;
  type lt_remote_data_tab_type is table of clob index by binary_integer;
  lv_remote_data_tab lt_remote_data_tab_type;
  begin
    begin
    -- Connect to FTP site and get data from file.
    lv_connection := szkftpx.login(lv_site, lv_port, lv_user, lv_pass);
    szkftpx.ascii(p_conn =&gt; lv_connection);
  
    -- Get a list of files.
    szkftpx.nlst(p_conn  =&gt; lv_connection,
                 p_dir   =&gt; './' || substr(lv_filename,1,20) || '*',
                 p_list  =&gt; lv_list);
  
    -- Loop through the files.
    for file_index in 1..lv_list.count
    loop
      begin
        lv_remote_data_tab (file_index) 
          := szkftpx.get_remote_ascii_data (
               p_conn =&gt; lv_connection,
               p_file =&gt; lv_list(file_index));
      exception
        when others then null;
      end;
    end loop;
  
    szkftpx.logout(lv_connection);
  exception
    when others then null;
  end;
  </code></pre>
  
  <p>/* HERE IS LINE 186, RIGHT AT THE FOR LOOP BELOW.  IT LOOKS LIKE I MAY NEED TO INITIALIZE THE COLLECTION "lv_examinee_tab" BUT I'M NOT SURE HOW OR WHERE IN THE CODE I SHOULD DO THIS.
  */</p>
  
  <pre><code>for file_index2 in 1..lv_list.count
  loop
    if lv_remote_data_tab.exists (file_index2)
    then
      if dbms_lob.getlength(lv_remote_data_tab (file_index2)) &gt; 0
      then
        -- Parse clob into collection.
        lv_examinee_tab := f_clob2tab (lv_remote_data_tab (file_index2));
  
        -- Loop through collection
        for i in 1..lv_examinee_tab.count
        loop
          lv_field_tab.delete;
  
          -- Parse each record in collection, putting comma-separated fields in field collection.
          declare
            lv_string        varchar2(2000):=replace(lv_examinee_tab(i),',',', '); 
          begin
            for r in
              (select regexp_substr(lv_string,'[^,]+',1,level) my_field   
                 from dual   
              connect by level &lt;= length(regexp_replace(lv_string,'[^,]+')) + 1)   
            loop
              lv_field_tab(lv_field_tab.count + 1) := trim(r.my_field);  
            end loop;
          end;
  
          if lv_field_tab(1) &lt;&gt; 'Last Modified'
          then
            -- Assemble field in a record and send back to caller.
            pipe row (baninst1.scf_pert_test_examinee(
                        lv_field_tab(1),
                        lv_field_tab(2),
                        lv_field_tab(3),
                        lv_field_tab(4),
                        lv_field_tab(5),
                        lv_field_tab(6),
                        lv_field_tab(7),
                        lv_field_tab(8),
                        lv_field_tab(9),
                        lv_field_tab(10),
                        lv_field_tab(11),
                        lv_field_tab(12),
                        lv_field_tab(13),
                        lv_field_tab(14),
                        lv_field_tab(15),
                        lv_field_tab(16),
                        lv_field_tab(17)));
          end if;
        end loop;
      end if;
    end if;
  end loop;
  
  end f_get_pert_examinees;
  </code></pre>