Skip to Main Content

SQL & PL/SQL

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!

Oracle system trigger fired twice on drop table

897305Nov 1 2011 — edited Nov 1 2011
Hi all,

I am using Oracle 11g on windows 2003 server R2 standard edition service pack 2. I am trying to create a trigger within a schema called "inventory" by logging in as the schema owner. Here is my code for the same:
 create or replace TRIGGER AUDIT_SYS_TR_TEST
   AFTER  ALTER OR DROP ON DATABASE
  BEGIN
    IF(ora_sysevent = 'DROP' AND UPPER(ora_login_user) not in ('SYS','SYSTEM')) THEN
     DBMS_OUTPUT.PUT_LINE(ora_sysevent);
    ELSIF(ora_sysevent = 'ALTER' AND UPPER(ora_login_user) not in ('SYS','SYSTEM')) THEN
     DBMS_OUTPUT.PUT_LINE(ora_sysevent);
    END IF;
  END; 
The aim is to fire the trigger whenever alter or drop occurs on a database object(ie any database object). So I created a table called trigtest like this within the same schema as the trigger:

CREATE TABLE TRIGTEST(COL1 VARCHAR(20));
Then I tried dropping the table:
DROP TABLE TRIGTEST;
This is what I got as serveroutput after the drop statement :

ALTER
DROP

Can someone please throw some light as to why both the alter and drop events are being fired when only the drop statement is called?
This post has been answered by odie_63 on Nov 1 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 29 2011
Added on Nov 1 2011
5 comments
340 views