I have a performance issue that maybe you could help with. When I open the cursor, I then run several other SELECT statements to retrieve values using the variables from the cursor (see below). This seems to slow down the whole proc; I assume this is because the switch between PL/SQL and SQL engine. Would using table collections help? But as I see, since I need different columns from different tables I would need to have several different collections, how could I output everything in one record to return the result set?
CREATE OR REPLACE procedure sp_test (in_input in number)
as
v_calc number;
v_calc_res number;
v1 number;
v2 number;
v3 number;
CURSOR C_test IS
select col1 from test where col1 = in_input;
begin
open c_test
loop
fetch c_test into v_calc;
select col1 into v1 from t1;
select col1 into v2 from t2;
select col1 into v3 from t3;
v_calc_res := v_calc * 5 * v1 * v2 * v3;
dbms_output.put_line(v_calc_res);
end loop;
end sp_test;
/