概述
我们在调用存储过程的时候,发生异常,经常无法判断是那个存储过程发生了错误,而导致问题不好排查,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、语法:
![fe4b97ec9456d357b91f84dd21cc2488.png](https://i-blog.csdnimg.cn/blog_migrate/cd96c98dc8194e78f1208ab0b1b24b70.jpeg)
2、参数解释:
![dc5626059897294e5584dc5e2da012b2.png](https://i-blog.csdnimg.cn/blog_migrate/253a1e514f693ced822175871104ae23.jpeg)
二、实验
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;/
![77f57915b0f6ee02fc2c759753792552.png](https://i-blog.csdnimg.cn/blog_migrate/4311a58876ef1f392b4c7f65df1c346d.jpeg)
2、测试
set serveroutput on;exec parent_proc;
![fd5c6a1d928f43c5d6c5e5bc6dcfad07.png](https://i-blog.csdnimg.cn/blog_migrate/8d931ffdc6ae9a600d5b05ea68cf8d5a.jpeg)
觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~
![03de0e8a6a26ede61c871244fb7a7b48.gif](https://i-blog.csdnimg.cn/blog_migrate/a121aa68a875fa1f3ac07c06e19a9905.gif)