Hi
Need a help with the below scenario only with PL/SQL.
I'm trying out the following:
- My table has 2M recs. Need to fetch 50K records in bulk into an object
- within the each iteration I want to refer the 50K records like a table inside a select statement and join with another table
I don't want to loop through using forall / for loop
Eg. I've tried this:
Create type my_typ as object ( id1 Number(10), id2 Number(10) );
Create type my_typ_tbl as table of my_typ;
Declare
v_my_tbl my_typ_tbl;
cursor r is select rownum, object_id from all_objects;
begin
open r;
loop
fetch r
bulk collect
into v_my_tbl
limit 50000;
select count(*) into v_count from table(v_my_tbl); -- Just a sample the actual select combines other tables.
exit when r%notfound;
end loop;
end;
/
I seem to be combining 2 concepts of collections here and am running into errors.
How do I fetch the 50K records in bulk and then use them inside a select to fetch counts from another table.
Could someone guide me please.
Thanks in advance.
Sai