OWA_UTIL.WHO_CALLED_ME解析

11 篇文章 0 订阅

说明:

在撰写ETL调度工具时,在往日志表里面写调度日志时,需要写入当前执行的用户名称、执行作业的名称等信息,所以就想到了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代码单元的信息(以输出参数的形式)。--为照顾英文能力差的朋友

语法:

 

参数解释:

ParameterDescription

owner

The owner of the program unit.--程序单元的所有者。

name

The name of the program unit. This is the name of the package, if the calling program unit is wrapped in a package, or the name of the procedure or function if the calling program unit is a standalone procedure or function. If the calling program unit is part of an anonymous block, this is NULL.--程序单元的名称。这是包的名称(如果调用程序单元包装在包中),或者是过程或函数的名称(如果调用程序单元是独立的过程或函数)。如果调用程序单元是匿名块的一部分,则该值为NULL。

lineno

The line number within the program unit where the call was made.--调用所在程序单元中的行号。

caller_t

The type of program unit that made the call. The possibilities are: package body, anonymous block, procedure, and function. Procedure and function are only for standalone procedures and functions.--发出调用的程序单元的类型。可能性有:包体、匿名块、过程和函数。过程和函数仅用于独立的过程和函数。这一点很重要,如果过程在包里面,返回的是包名。

 案例:

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;

/

 下面进行测试:

--记得执行一下输出,要不然后面不显示的。

至此完毕,供参考。 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胖哥真不错

您的鼓励,将是我最大的坚持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值