DDL Trigger Oracle -


i've created 1 audit table record information object created in schema , whom.

hr@ssc> create table create_audit   2  ( created_date date,   3  object_type varchar2(30),   4  object_name varchar2(30),   5  created_by varchar2(20)); 

this trigger i've created:

  1      create or replace trigger create_trg_audit   2      after create on schema   3      begin   4      insert create_audit values   5     (sysdate, ora_dict_obj_typ, ora_dict_obj_name , ora_dict_obj_owner);   6*  end create_trg_audit; 

i'm receiving below error while creating ddl trigger:

hr@ssc> show error errors trigger create_trg_audit:  line/col error -------- ----------------------------------------------------------------- 2/5      pl/sql: sql statement ignored 3/16     pl/sql: ora-00984: column not allowed here 

can't give insert command in ddl triggers?

hr@ssc> select object_type, object_name ,owner all_objects last_ddl_time > sysdate-10; 

you have typo; insert refers ora_dict_obj_typ instead of (valid) ora_dict_obj_type, you're missing final 'e'. event attribute functions documentation lists valid values, , shows them being used in values() clause of insert.

with event attribute function name corrected create trigger statement works:

create or replace trigger create_trg_audit after create on schema begin    insert create_audit (created_date, object_type, object_name, created_by)    values (sysdate, ora_dict_obj_type, ora_dict_obj_name, ora_dict_obj_owner); end create_trg_audit; /  trigger create_trg_audit compiled  show errors  no errors. 

and wanted:

create table t42 (id number);  table t42 created.  select * create_audit;  created_date object_type          object_name          created_by     ------------ -------------------- -------------------- --------------- 2016-04-20   table                t42                  myuser        

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -