Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how do DDL triggers AFTER ALTER work?

User_5OAFPApr 3 2014 — edited Apr 8 2014

I thought that general framework for DDL triggers defined AFTER ALTER was like this:

-- implicit COMMIT before DDL statement (here: ALTER TABLE)

-- DDL statement

-- implicit COMMIT after DDL statement (here: ALTER TABLE)

-- AFTER ALTER DDL trigger fires

And I also thought that everything is inside that trigger would see "new" DDL code as introduced by ALTER TABLE statement. But it looks like I miss something about this situation because the following trigger fires dbms_metadata.get_ddl procedure and sees "old" DDL code (before ALTER TABLE statement).

What do I miss? Could you give me some hints about this behavior? If I shouldn't expect returned DDL to be "current" then why I shouldn't?

Thank you

/* all done in SCOTT schema */

create table y ( col1 varchar2(5) );

create table t ( dt date default sysdate, d varchar2(4000) );

create or replace trigger trg

after ALTER ON scott.SCHEMA

declare

  v_d varchar2(4000);

begin

  select cast(dbms_metadata.get_ddl('TABLE', sys.dictionary_obj_name, sys.dictionary_obj_owner) as varchar2(4000))

  into v_d

  from dual;

  insert into t(d) values (v_d);

end;

alter table y add col2 int;

select * from t; -- here is "old" DDL with col1 only

This post has been answered by unknown-7404 on Apr 3 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2014
Added on Apr 3 2014
11 comments
5,483 views