OmarLittle
OmarLittle

Reputation: 503

Get name of nested procedure that called my procedure

I am new to PL SQL and I want to know is there a way (method/function/etc) that I can get the name of nested procedure that called my procedure?

For example, I have my_procedure and it gets called by another_procedure nested in another_package. I want a funciton/method implemented in my_procedure that tells me every time which nested procedure called my_procedure, which is, in this example, my_procedure.

I am using owa_util.who_called_me for getting the package and owner name.

Upvotes: 0

Views: 482

Answers (1)

William Robertson
William Robertson

Reputation: 16001

Demo procedure:

create or replace procedure demo
as
    k_this   constant varchar2(300) := utl_call_stack.concatenate_subprogram(utl_call_stack.subprogram(1));
    k_caller constant varchar2(300) := utl_call_stack.concatenate_subprogram(utl_call_stack.subprogram(2));
begin
    dbms_output.put_line(k_this || ' called from ' || k_caller);
end demo;

Package to call it:

create or replace package testit
as
    procedure do_something;
end testit;
/

create or replace package body testit
as
    procedure do_something is
    begin
        demo;
    end do_something;
end testit;
/

Test:

begin
    testit.do_something;
end;
/

DEMO called from TESTIT.DO_SOMETHING

Upvotes: 2

Related Questions