In my PL/SQL block, I have these queries.
Query I
select emp_id from employee where emp_type = 'MANAGER';
Query II
select * from products where prod_owner in (list selected in previous query)
Query I retrieves a list of values,which will be used in the IN clause of Query II.
My exact problem is this. I am not able to find a place holder for the list retrieved in Query I, which I would like to use in Query II. Please note that I have grossly simplified the queries in order to explain it here. So, please don't suggest that I can achieve this by having query I as a sub query inside query II. That is simply ruled out in the real case scenario.
I tried using Varray. But, I faced these problems.
a) The first query needs to be declared as a cursor and I have to loop through the cursor to populate the array.
b) There is no way I can execute the second query using the varray. Please note that I don't want to build the queries in form of strings.
Please let me know if you have a solution for this.
Query I
select emp_id from employee where emp_type = 'MANAGER';
Query II
select * from products where prod_owner in (list selected in previous query)
Query I retrieves a list of values,which will be used in the IN clause of Query II.
My exact problem is this. I am not able to find a place holder for the list retrieved in Query I, which I would like to use in Query II. Please note that I have grossly simplified the queries in order to explain it here. So, please don't suggest that I can achieve this by having query I as a sub query inside query II. That is simply ruled out in the real case scenario.
I tried using Varray. But, I faced these problems.
a) The first query needs to be declared as a cursor and I have to loop through the cursor to populate the array.
b) There is no way I can execute the second query using the varray. Please note that I don't want to build the queries in form of strings.
Please let me know if you have a solution for this.