ORACLE DDL觸發器

renjixinchina發表於2012-07-09
create or replace trigger tr_ddl
before ddl on database
declare
  l_errmsg varchar2(100) := '你無權修改,專案組!!!';
begin
  if (Ora_dict_obj_type = 'TABLE' or Ora_dict_obj_type='INDEX') AND
  (ora_dict_obj_owner ='NCCMOLTP_HNS' or ora_dict_obj_owner='NCCMHIST_HNS')  and  ora_login_user not in ('SYS', 'SYSTEM') and
     (Ora_sysevent = 'ALTER' OR Ora_sysevent = 'DROP') then
    raise_application_error(-20001,
                            ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' ||
                            l_errmsg);
  end if;
 
   if (Ora_dict_obj_type = 'TRIGGER' ) AND
  (ora_dict_obj_owner ='NCCMOLTP_HNS' or ora_dict_obj_owner='NCCMHIST_HNS')  and  ora_login_user not in ('SYS', 'SYSTEM') and
     (Ora_sysevent = 'ALTER' OR Ora_sysevent = 'DROP' or Ora_sysevent = 'CREATE') then
    raise_application_error(-20001,
                            ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' ||
                            l_errmsg);
  end if;

exception
  when no_data_found then
    null;
end;
 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15747463/viewspace-734975/,如需轉載,請註明出處,否則將追究法律責任。

相關文章