title: How can I use a plsql table type in a sql query?
body: <p>Let me start off by saying I'm open to other ways of doing this, but right now, this is all I've been able to come up with.</p>
  
  <p>I'm working within a package.procedure and I am using a table type as an array/list to store IDs of records that match search criteria. Once I have compiled the list, I want to open a cursor that selects from a table where the record ID is in my list.</p>
  
  <p>Data structure:</p>
  
  <pre><code>TYPE i_array IS TABLE OF t_table.id_column%TYPE INDEX BY PLS_INTEGER;
  lt_results i_array;
  ln_count pls_integer;
  </code></pre>
  
  <p>Populating list:</p>
  
  <pre><code>    ln_count := 0;
      for recs in (select id_column from t_child where other_column = ls_criteria)
      loop
          ln_count := ln_count + 1;
          lt_results(ln_count);
      end loop;
  </code></pre>
  
  <p>Opening cursor and accessing list:</p>
  
  <pre><code>    open cur for 
          select col_a,
                 col_b,
                 col_c
          from t_table
          where id_column in (select lt_results(level)
                              from dual
                              connect by level &lt;= ln_count);
  </code></pre>