Select from all elements IN VARRAY
jjmdbApr 23 2012 — edited Apr 23 2012I'm trying to select from a table where all ID's are in a VARRAY I've populated. I've searched online and on the forums and cannot find an answer. Help is greatly appreciated.
EX.
SELECT ID BULK COLLECT INTO p_ID_1 FROM table_name WHERE contained_by = p_ID;
v_id_1 := v_id_1();
FOR i IN p_id_1.first .. p_id_1.last LOOP
v_id_1.extend();
v_id_1(v_id_1.last) := p_id_1(i);
END LOOP;
-- up to this point, my VARRAY is populated just fine Below is where I'm having trouble:
SELECT ID BULK COLLECT INTO p_id_2 FROM table_name_2 WHERE contained_by IN v_naid_1(1);
Everything works just fine when I run the query. The problem is that I want the query to select where contained_by IN (all elements in varray). Not just the first. How do I go about doing this? Can I do 'FIRST' throught 'LAST' somehow? I can't list all of the elements because there are potentially thousands.
Thanks!