Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: PL/SQL Automatic BULK
Bruce,
>>Can you tell if bulkification is performed without running the p/sql.
>If PLSQL_OPTIMIZE_LEVEL is set to 2 the feature is activated.
Furthermore, plsql_debug must be false.
K.B1D5.AVALOQ> set serveroutput on size 100000 K.B1D5.AVALOQ> create table t(x number);
Table created.
K.B1D5.AVALOQ> insert into t select 1 from all_objects where rownum < 10000;
9999 rows created.
K.B1D5.AVALOQ> show parameter plsql_optimize_level
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ plsql_optimize_level integer 2K.B1D5.AVALOQ> alter session set plsql_debug=3Dfalse;
Session altered.
K.B1D5.AVALOQ> create or replace procedure prefetch(
2 i_x pls_integer :=3D 13 )
5 l_cnt pls_integer :=3D 0; 6 l_x number;7 begin
13 l_x :=3D c.x; 14 l_cnt :=3D l_cnt + 1; 15 rollback to sp;
Procedure created.
K.B1D5.AVALOQ> exec prefetch
Prefetched: 100
PL/SQL procedure successfully completed.
K.B1D5.AVALOQ> alter session set plsql_debug=3Dtrue;
Session altered.
K.B1D5.AVALOQ> alter procedure prefetch compile;
Procedure altered.
K.B1D5.AVALOQ> exec prefetch
Prefetched: 1
PL/SQL procedure successfully completed.
As pointed out by Chris, the implicit bulkification only works for implicit cursors:
K.B1D5.AVALOQ> -- No automatic prefetching for explicit cursors K.B1D5.AVALOQ> alter session set plsql_debug=3Dfalse;
Session altered.
K.B1D5.AVALOQ> set serveroutput on
K.B1D5.AVALOQ> declare
2 l_cur sys_refcursor; 3 l_cnt pls_integer :=3D 0; 4 l_t t%rowtype;5 begin
10 fetch l_cur into l_t; 11 exit when l_cur%notfound; 12 l_cnt :=3D l_cnt + 1; 13 if l_cnt =3D 1 then 14 rollback to sp; 15 end if;
19 dbms_output.put_line('Fetched: ' || l_cnt); 20 raise;
Regards,
Martin
-- http://www.freelists.org/webpage/oracle-lReceived on Fri Mar 18 2005 - 02:44:12 CST