Suppose I have an AFTER ALTER
trigger on my Oracle database and I rename some database object (ALTER ... RENAME TO ...
). Within the trigger, how do I determine the new name of the database object? It seems that the ORA_DICT_OBJ_OWNER
, ORA_DICT_OBJ_NAME
and ORA_DICT_OBJ_TYPE
functions all return the old values of the database object.
For example:
CREATE OR REPLACE TRIGGER ADAM_BEFORE_AFTER BEFORE ALTER ON DATABASE
BEGIN
DBMS_OUTPUT.put_line('Before alter: ' || ora_dict_obj_owner || '.' || ora_dict_obj_name || ' (' || ora_dict_obj_type || ')');
END;
CREATE OR REPLACE TRIGGER ADAM_AFTER_ALTER AFTER ALTER ON DATABASE
BEGIN
DBMS_OUTPUT.put_line('After alter: ' || ora_dict_obj_owner || '.' || ora_dict_obj_name || ' (' || ora_dict_obj_type || ')');
END;
Suppose I rename a table:
ALTER TABLE USELESS_TABLE9 RENAME TO USELESS_TABLE10
The database outputs this:
Before alter: DEVELOPER.USELESS_TABLE9 (TABLE) After alter: DEVELOPER.USELESS_TABLE9 (TABLE)
Update: Unfortunately, the output I presented above was incorrect. The output was actually being generated by a BEFORE DDL
trigger and an AFTER DDL
trigger I had created earlier, not by the BEFORE RENAME
and AFTER RENAME
triggers. I will continue to investigate why the BEFORE RENAME
and AFTER RENAME
triggers are not firing...
Update: It appears that the BEFORE RENAME
and AFTER RENAME
triggers refuse to fire, but the BEFORE ALTER
and AFTER ALTER
triggers do. I have updated the question accordingly.