Note that there are some explanatory texts on larger screens.

plurals
  1. POOracle: How do I determine the NEW name of an object in an "AFTER ALTER" trigger?
    primarykey
    data
    text
    <p>Suppose I have an <code>AFTER ALTER</code> trigger on my Oracle database and I rename some database object (<code>ALTER ... RENAME TO ...</code>). Within the trigger, how do I determine the <strong>new</strong> name of the database object? It seems that the <code>ORA_DICT_OBJ_OWNER</code>, <code>ORA_DICT_OBJ_NAME</code> and <code>ORA_DICT_OBJ_TYPE</code> functions all return the <strong>old</strong> values of the database object.</p> <p>For example:</p> <pre><code>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; </code></pre> <p>Suppose I rename a table:</p> <pre><code>ALTER TABLE USELESS_TABLE9 RENAME TO USELESS_TABLE10 </code></pre> <p>The database outputs this:</p> <pre> Before alter: DEVELOPER.USELESS_TABLE9 (TABLE) After alter: DEVELOPER.USELESS_TABLE9 (TABLE) </pre> <p><strong>Update:</strong> Unfortunately, the output I presented above was incorrect. The output was actually being generated by a <code>BEFORE DDL</code> trigger and an <code>AFTER DDL</code> trigger I had created earlier, <strong>not</strong> by the <code>BEFORE RENAME</code> and <code>AFTER RENAME</code> triggers. I will continue to investigate why the <code>BEFORE RENAME</code> and <code>AFTER RENAME</code> triggers are not firing...</p> <p><strong>Update:</strong> It appears that the <code>BEFORE RENAME</code> and <code>AFTER RENAME</code> triggers refuse to fire, but the <code>BEFORE ALTER</code> and <code>AFTER ALTER</code> triggers do. I have updated the question accordingly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload