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!

Using collection list in subquery to restrict rows

531473May 20 2008 — edited May 21 2008
How can I use a collection list in a subquery?

Something like this:

TYPE listOfIDs_t IS TABLE OF NUMBER;
v_listOfIDs_arr listOfIDs_t;

CURSOR c1 IS
SELECT *
FROM tbl
WHERE id IN (SELECT column_value
FROM TABLE ( CAST(v_listOfIDs_arr AS listOfIDs_t ))
);

When I try something like this, I get "invalid datatype" on the collection type, listOfIDs_t. Any suggestions? Basically, I want to use the list of values in my collection to restrict my cursor/query without having to loop through my collection and execute the cursor/query each time.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 18 2008
Added on May 20 2008
7 comments
1,224 views