Tom Fox, November 15, 2007 - 7:45 pm UTC
And DBA_TRIGGERS has a column named TABLE_NAME and OWNER which will show you the table name and owner to which the trigger belongs.
wouldn't it be nice ...
Sokrates, November 16, 2007 - 6:01 am UTC
... if we would have a
dbms_utility.call_stack
returning some data structure
to access the real call stack ?
(and not access the *formatted* call stack and have to parse it to get the call stack out of the format)
Cut the stack
Dmytro Dekhtyaryuk, November 16, 2007 - 6:33 am UTC
Nice idea !
... And if we want to get only trigger name,
we can cut the message and then really search in Data Dictionary (all_triggers) for table name ...
Something like
SQL> set serveroutput on
SQL>
SQL> create or replace trigger t_trigger
2 before insert on t
3 declare
4 v_trig_name VARCHAR2(30);
5 v_table_name VARCHAR2(30);
6 begin
7 v_trig_name := rtrim(substr(dbms_utility.format_call_stack,
8 INSTR(dbms_utility.format_call_stack,'.',-1)+1),chr(10));
9 SELECT table_name INTO v_table_name
10 FROM all_triggers
11 WHERE trigger_name = v_trig_name;
12 dbms_output.put_line( ' Trigger:'||v_trig_name||
13 ' Table:'||v_table_name);
14 end;
15 /
Trigger created
SQL> insert into t values (2);
Trigger:T_TRIGGER Table:T
1 row inserted
SQL>
(Well, also owner check for SELECT ...)