概述
我們在調用存儲過程的時候,發生異常,經常無法判斷是那個存儲過程發生了錯誤,而導致問題不好排查,Oracle提供了一個在運行過程中獲取存儲過程名字的過程:OWA_UTIL.WHO_CALLED_ME.下面一起來看看怎麼用吧~
一、OWA_UTIL.WHO_CALLED_ME Procedure
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方面的內容,感興趣的朋友可以關注下~