In Oracle9i, the bulk collect method is added for PL/SQL. You can integrate the retrieved records into a batch of Oracle memory tables to improve the performance of the select into, fetch into or returning into clause.
Example:
Create or replace type performance_obj as object
(
Netlatency number (10)
); Create or replace type performance_tab is table of performance_obj;
Create or replace package pkg_test
As
Type performance_cur is ref cursor;
Procedure spgetperfchartinfo (p_confname in varchar2, p_ret out performance_cur );
End pkg_test;
/
Create or replace package body pkg_test
Procedure spgetperfchartinfo (p_confname in varchar2, p_ret out performance_cur)
Is
V1 number: = 0;
V2 number: = 0;
V3 number: = 0;
V_tab performance_tab: = performance_tab ();
Begin
Select performance_obj (C. netlatency) Bulk collect into v_tab
From wmattendeeinfo A, wbxsite B, wmclientperformancedata_tmp C where lower (A. confname) like '%' | p_confname | '%'
And (A. jointime> sysdate-1/3 and A. leavetime is null) and lower (A. sitename) like '% software %'
And a. siteid = B. siteid and A. confid = C. confid and A. siteid = C. siteid;
Select count (*) into V1 from table (cast (v_tab as performance_tab) where netlatency> 0 and netlatency <= 500;
Select count (*) into V2 from table (cast (v_tab as performance_tab) where netlatency> 500 and netlatency <= 1000;
Select count (*) into V3 from table (cast (v_tab as performance_tab) where netlatency> 1000;
Open p_ret for select V1 as good, v2 as medium, V3 as poor from dual;
End spgetperfchartinfo;
End pkg_test;
/
Test Results
Sqlplus> set timing on;
Sqlplus> variable C refcursor;
Sqlplus> exec pkg_test.spgetperfchartinfo ('Meeting ',: C );
Sqlplus> Print C;