I have a table (Oracle 11g) on โโwhich several packages / stored processes run DML instructions. I want to capture the name of the package / procedure that issued the DML in the table using the trigger and registering it in the logging table.
For instance:
The package MY_PACK.MY_PROC() throws insert into... for the table mytab . I would develop a trigger on mytab that should be able to capture the name of the package / procedure that issued insert into.. and save this information in another my_tab_log table.
I did some searching and found that $$PLSQL_UNIT and $$PLSQL_LINE can indicate the name of the procedure, but then if these variables are used from the trigger, the name of the trigger will be written instead of the name of the package / procedure that issued the DML instruction.
like -
CREATE OR REPLACE TRIGGER my_trg AFTER INSERT OR UPDATE OR DELETE ON MY_TAB FOR EACH ROW BEGIN IF INSERTING THEN insert into my_tab_log values('INSERTED A ROW' sysdate, $$PLSQL_UNIT); END IF;
Now, since $$ PLSQL_UNIT is a conditional compilation directive. It is allowed when compiling / recompiling PL / SQL code. Unfortunately, $$ PLSQL_UNIT inside a trigger is nothing more than the name of the trigger and is resolved when compilation starts.
I also found the owa_util.who_called_me procedure, but could not wrap my head around how I could use it to meet my needs. Is it possible to achieve what I want without modifying the actual packages / stored procedures that trigger the DML statements? I canโt change these programs, and this is a strict restriction on him, so this is not an option.
source share