title: PLSQL - How to retrieve values into a collection given an array of values?
body: <p>I have a procedure that accepts an array of folder IDs and needs to return a list of document IDs. Folders are associated to documents in a one-to-many relationship--there are many documents for each folder. Specifically, there is a documents table which has a parent_folderid fk to the folders table.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>PROCEDURE get_folder_documents_ (
      paa_folderids_i IN gtyp_folderids_table
  ) IS                                                                                 
      lnt_temp_docids       &amp;&amp;MATTER_SCHEMA..docid_tab := &amp;&amp;MATTER_SCHEMA..docid_tab();
      lv_current_table_size NUMBER := gnt_documentids.COUNT;
  BEGIN                                                     
      FOR i IN paa_folderids_i.FIRST .. paa_folderids_i.LAST
      LOOP                 
          SELECT documentid
            BULK COLLECT INTO lnt_temp_docids
            FROM t$documents
           WHERE parent_folderid = paa_folderids_i(i);
  
          FOR j IN 1 .. lnt_temp_docids.COUNT
          LOOP                                                   
              lv_current_table_size := lv_current_table_size + 1;
  
              gnt_documentids.EXTEND(1);                                   
              gnt_documentids(lv_current_table_size) := lnt_temp_docids(j);
          END LOOP;
      END LOOP;
  END get_folder_documents_;
  </code></pre>
  
  <p>Is there a better way?</p>