ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORACLE DDL触发器

ORACLE DDL触发器

原创 Linux操作系统 作者:renjixinchina 时间:2012-07-09 17:05:30 0 删除 编辑
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/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 查看日志
请登录后发表评论 登录
全部评论

注册时间:2011-01-30

  • 博文量
    373
  • 访问量
    2047831