I have a table (Oracle 11g) on which multiple packages/stored procs run DML statements. I want to capture the package/procedure name which issued the DML on the table using
$$PLSQL_UNIT
would only provide the package name, not the name of the procedure within the package. The same is true of who_called_me
.
owa_util.who_called_me
is based on a little utility written by the inestimable Mr Kyte. If you take a peek at his source code here you will see that the routine gets its information from the call stack. Hence the information it offers is:
These admittedly frustrating limitations are down to overloading: we can create packaged procedures with the same name but different signatures. Consequently "procedure name" is not particularly useful to the system when it comes to identifying which piece of code is operating.
Anyway, if you want to have a play with who_called_me
, it takes four out parameters like this:
create or replace trigger my_trg
before insert or update on my_tab
for each row
declare
l_owner varchar2(30);
l_name varchar2(30);
l_line pls_integer;
l_type varchar2(30);
begin
owa_util.who_called_me(l_owner,l_name,l_line,l_type);
IF INSERTING THEN
insert into my_tab_log values('INSERTED A ROW'
sysdate,
l_owner||'.'||l_name);
END IF;
end;
/