CMD> cat wrapped.sql CREATE OR REPLACE FUNCTION wrapped (l PLS_INTEGER) RETURN NUMBER IS cnt number; BEGIN FOR i IN 1.. l LOOP select count(*) into cnt from employees; select count(*) into cnt from departments; END LOOP; RETURN 0; END wrapped; / cat unwrapped.sql CREATE OR REPLACE FUNCTION unwrapped(l PLS_INTEGER) RETURN NUMBER IS cnt NUMBER; BEGIN FOR i IN 1 .. l LOOP SELECT COUNT(*) INTO cnt FROM employees; SELECT COUNT(*) INTO cnt FROM departments; END LOOP; RETURN 0; END unwrapped; / wrap iname=wrapped.sql oname=output.sql SQL*PLUS> -- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production @output.sql @unwrapped.sql conn hr/hr@tcell alter session set max_dump_file_size=unlimited; alter session set tracefile_identifier = wrapped ; ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 8'; DECLARE c PLS_INTEGER := 0; BEGIN c := wrapped(2); END; / ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT OFF'; conn hr/hr@tcell alter session set max_dump_file_size=unlimited; alter session set tracefile_identifier = unwrapped ; ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 8'; DECLARE c PLS_INTEGER := 0; BEGIN c := unwrapped(2); END; / ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT OFF'; CMD> tkprof tcell_ora_7148_WRAPPED.trc tcell_ora_7148_WRAPPED.txt sys=no waits=yes sort=execpu ******************************************************************************** OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 6 0.01 0.04 0 0 0 0 Execute 6 0.00 0.00 0 0 0 3 Fetch 2 0.00 0.00 0 0 0 2 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 14 0.01 0.05 0 0 0 5 Misses in library cache during parse: 2 Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ SQL*Net message to client 8 0.00 0.00 SQL*Net message from client 8 0.01 0.04 OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 26 0.05 0.05 0 0 0 0 Execute 61 0.04 0.04 0 0 0 0 Fetch 99 0.02 0.05 20 212 0 214 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 186 0.12 0.16 20 212 0 214 Misses in library cache during parse: 11 Misses in library cache during execute: 9 Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 20 0.01 0.02 8 user SQL statements in session. 57 internal SQL statements in session. 65 SQL statements in session. ******************************************************************************** Trace file: tcell_ora_7148_WRAPPED.trc Trace file compatibility: 10.01.00 Sort options: execpu 1 session in tracefile. 8 user SQL statements in trace file. 57 internal SQL statements in trace file. 65 SQL statements in trace file. 15 unique SQL statements in trace file. 606 lines in trace file. 0 elapsed seconds in trace file. tkprof tcell_ora_7154_UNWRAPPED.trc tcell_ora_7154_UNWRAPPED.txt sys=no waits=yes sort=execpu ******************************************************************************** OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 6 0.01 0.01 0 0 0 0 Execute 6 0.00 0.00 0 0 0 3 Fetch 2 0.00 0.00 0 0 0 2 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 14 0.01 0.01 0 0 0 5 Misses in library cache during parse: 1 Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ SQL*Net message to client 8 0.00 0.00 SQL*Net message from client 8 0.01 0.04 OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 2 0.00 0.00 0 0 0 0 Execute 4 0.00 0.00 0 0 0 0 Fetch 4 0.00 0.00 2 4 0 4 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 10 0.00 0.00 2 4 0 4 Misses in library cache during parse: 0 Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 2 0.00 0.00 8 user SQL statements in session. 0 internal SQL statements in session. 8 SQL statements in session. ******************************************************************************** Trace file: tcell_ora_7154_UNWRAPPED.trc Trace file compatibility: 10.01.00 Sort options: execpu 1 session in tracefile. 8 user SQL statements in trace file. 0 internal SQL statements in trace file. 8 SQL statements in trace file. 6 unique SQL statements in trace file. 98 lines in trace file. 0 elapsed seconds in trace file.