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!

Multiple rows into variable

608221Nov 13 2007 — edited Nov 13 2007
Hi,
Is there a way to store result of SQL query that returns multiple rows to a variable and then use that variable in the another query as part of the IN query?
I am using this in a stored procedure.

Simplified example of how it should work:

1. First query selects one column from multiple rows.
SELECT row_id INTO some_variable FROM some_table;
-row_id column is integer type.

2. Next query uses some_variable
SELECT * FROM another_table WHERE row_id IN (some_variable);

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 11 2007
Added on Nov 13 2007
4 comments
1,068 views