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.
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.
Data structure:
TYPE i_array IS TABLE OF t_table.id_column%TYPE INDEX BY PLS_INTEGER;
lt_results i_array;
ln_count pls_integer;
Populating list:
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;
Opening cursor and accessing list:
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 <= ln_count);
create or replace type .... Better yet, why are you using an array at all? Why not dowhere id_column in (select id_column from t_child where ...)in your cur ref cursor??ls_criteriais a substring of a text input .["Atlanta", "Thursday"]each string will be used as search criteria. The records that match will be added to the list for the return cursor