我们在调用存储过程的时候,发生异常,经常无法判断是那个存储过程发生了错误,而导致问题不好排查,Oracle提供了一个在运行过程中获取存储过程名字的过程:OWA_UTIL.WHO_CALLED_ME.下面一起来看看怎么用吧~
This procedure returns information (in the form of output parameters) about the PL/SQL code unit that invoked it.
这个过程返回有关调用它的PL/SQL代码单元的信息(以输出参数的形式)
1、语法:
2、参数解释:
1、创建存储过程
create or replace procedure child_proc(id number) as
owner_name VARCHAR2(100);
caller_name VARCHAR2(100);
line_number NUMBER;
caller_type VARCHAR2(100);
begin
OWA_UTIL.WHO_CALLED_ME(owner_name, caller_name, line_number, caller_type);
DBMS_OUTPUT.put_line('【id:】 ' || id || ' 【caller_type:】 ' || caller_type ||
' 【owner_name:】 ' || owner_name ||
' 【caller_name:】 ' || caller_name ||
' 【line_number:】 ' || line_number);
end;
/
create or replace procedure parent_proc as
v_child_proc VARCHAR2(100) := 'begin child_proc (1); end;';
begin
execute immediate v_child_proc;
child_proc(2);
end;
/
2、测试
set serveroutput on;
exec parent_proc;
觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~