说明:
在撰写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代码单元的信息(以输出参数的形式)。--为照顾英文能力差的朋友
语法:
参数解释:
Parameter | Description |
---|---|
| The owner of the program unit.--程序单元的所有者。 |
| 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 |
| The line number within the program unit where the call was made.--调用所在程序单元中的行号。 |
| 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;
/
下面进行测试:
--记得执行一下输出,要不然后面不显示的。
至此完毕,供参考。