Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Select from all elements IN VARRAY

jjmdbApr 23 2012 — edited Apr 23 2012
I'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!
This post has been answered by Solomon Yakobson on Apr 23 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2012
Added on Apr 23 2012
7 comments
2,129 views