如
the documentation中所述:
DEBUG
Has the same effect as PLsql_OPTIMIZE_LEVEL=1—instructs the PL/sql compiler to generate and store the code for use by the PL/sql debugger. Oracle recommends using PLsql_OPTIMIZE_LEVEL=1 instead of DEBUG.
因此,您可以在创建对象之前或重新编译模式之前设置它.为了匹配sql Developer在“编译调试”时所做的事情,您还需要将PLsql_DEBUG设置为true.这是一个快速演示:
create or replace package p42 as
function f return number;
end p42;
/
create or replace package body p42 as
function f return number is
begin
return 42;
end f;
end p42;
/
select name,type,plsql_optimize_level,plsql_debug
from user_plsql_object_settings where name = 'P42';
NAME TYPE PLsql_OPTIMIZE_LEVEL PLsql_DEBUG
------------------------------ ------------ -------------------- -----------
P42 PACKAGE 2 FALSE
P42 PACKAGE BODY 2 FALSE
alter session set plsql_optimize_level = 1;
alter session set plsql_debug = true;
exec dbms_utility.compile_schema(user);
select name,plsql_debug
from user_plsql_object_settings where name = 'P42';
NAME TYPE PLsql_OPTIMIZE_LEVEL PLsql_DEBUG
------------------------------ ------------ -------------------- -----------
P42 PACKAGE 1 TRUE
P42 PACKAGE BODY 1 TRUE
当然,你可以在创建对象之前改变你的会话,但是如果你知道你总是要总是重新编译模式 – 如果你必须重新编译所有东西,而不仅仅是无效的对象 – 那么等到那时可能是好.但是如果您确实在启用调试的情况下创建对象,您仍然可以使用以下命令重新编译并保留它:
DBMS_UTILITY.COMPILE_SCHEMA(schema => user,reuse_settings => true);
…如果要重新编译所有内容,或者只想重新编译无效对象:
DBMS_UTILITY.COMPILE_SCHEMA(schema => user,compile_all => false,reuse_settings => true);