I am writing PL / SQL and found that I am getting into a repeating pattern:
cursor c_curs1 is
select a, b, c
from (...) big_subquery_1
where big_subquery_1.a_ind = 'Y'
cursor c_curs2 is
select a, b, c
from (...) big_subquery_2
where big_subquery_2.b_ind = 'R'
cursor c_curs3 is
select a, b, c
from (...) big_subquery_3
where big_subquery_3.c_ind = 'M'
...
type t_curs1_tab is table of c_curs1;
type t_curs2_tab is table of c_curs2;
type t_curs3_tab is table of c_curs3;
...
v_curs1_results t_curs1_tab := t_curs1_tab();
v_curs2_results t_curs2_tab := t_curs2_tab();
v_curs3_results t_curs3_tab := t_curs3_tab();
Then, when processing the results, I have this code:
open c_curs1;
fetch c_curs1 bulk collect into v_curs1_results;
close c_curs1;
if v_curs1_results.first is not null and v_curs1_results.last is not null then
for i in v_curs1_results.first .. v_curs1_results.last loop
/*Do something with field a in the results
Do something with field b in the results
Do something with field c in the results*/
....
end loop;
end if;
The code in the processing loop is the same for all cursors, since all 3 cursors return a,b,c- the only difference the cursor refers to. I wanted to reorganize this into some sort of shared processor with a result set, but I'm stuck here:
procedure sp_process_collection(in_collection t_curs1_tab) is ...
v_curs1_results, v_curs2_results PLS-00306 wrong number of types or arguments.... , ? ( , ), , , . , , PL/SQL. , PL/SQL (, , Java/# ), , , .
( Oracle 10g)