ORACLE 11G 触发器调试记录Error: PLS-00201: identifier'SYS.DBMS_SYSTEM' must be declared

1,触发器内容如下

CREATE OR REPLACE TRIGGER"LOGON_DENIED_TO_ALERT"

 AFTER servererror ON DATABASE

DECLARE

 message   VARCHAR2(168);

 ip        VARCHAR2(15);

 v_os_user VARCHAR2(80);

 v_module  VARCHAR2(50);

 v_action  VARCHAR2(50);

 v_pid     VARCHAR2(10);

 v_sid     NUMBER;

 v_program VARCHAR2(48);

BEGIN

  IF(ora_is_servererror(1017)) THEN

 

   -- get ip FOR remote connections :

   IF upper(sys_context('userenv', 'network_protocol')) = 'TCP' THEN

     ip := sys_context('userenv', 'ip_address');

   END IF;

 

   SELECT sid INTO v_sid FROM sys.v_$mystat WHERE rownum < 2;

   SELECT p.spid, v.program

     INTO v_pid, v_program

     FROM v$process p, v$session v

    WHERE p.addr = v.paddr

      AND v.sid = v_sid;

 

   v_os_user := sys_context('userenv', 'os_user');

   dbms_application_info.read_module(v_module, v_action);

 

   message := to_char(SYSDATE, 'YYYYMMDD HH24MISS') ||

 

               ' logon denied from ' || nvl(ip,'localhost') || ' ' ||

               v_pid || ' ' || v_os_user || 'with ' || v_program || ' – ' ||

               v_module || ' ' || v_action;

 

   sys.dbms_system.ksdwrt(2, message);

 

  ENDIF;

END;

 

 

 ----------------------------------------------------------------------------------------------------------------
<版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!>
原博客地址:    http://blog.csdn.net/mchdba/article/details/45898169
原作者:黄杉 (mchdba)
----------------------------------------------------------------------------------------------------------------

 

 

2,执行报错信息:

 

Compilation errors for TRIGGERTIMDBA.LOGON_DENIED_TO_ALERT

 

Error: PL/SQL: ORA-00942: table or viewdoes not exist

Line: 20

Text: SELECT sid INTO v_sid FROMsys.v_$mystat WHERE rownum < 2;

 

Error: PL/SQL: SQL Statement ignored

Line: 20

Text: SELECT sid INTO v_sid FROMsys.v_$mystat WHERE rownum < 2;

 

Error: PL/SQL: ORA-00942: table or viewdoes not exist

Line: 23

Text: FROM v$process p, v$session v

 

Error: PL/SQL: SQL Statement ignored

Line: 21

Text: SELECT p.spid, v.program

 

Error: PLS-00201: identifier'SYS.DBMS_SYSTEM' must be declared

Line: 35

Text: sys.dbms_system.ksdwrt(2, message);

 

Error: PL/SQL: Statement ignored

Line: 35

Text: sys.dbms_system.ksdwrt(2, message);

 

 

解决办法

grant execute on sys.dbms_system to timdba;

 

3,再次执行还在报错:

Compilation errors for TRIGGER TIMDBA.LOGON_DENIED_TO_ALERT

 

Error: PL/SQL: ORA-00942: table or viewdoes not exist

Line: 20

Text: SELECT sid INTO v_sid FROMsys.v_$mystat WHERE rownum < 2;

 

Error: PL/SQL: SQL Statement ignored

Line: 20

Text: SELECT sid INTO v_sid FROMsys.v_$mystat WHERE rownum < 2;

 

Error: PL/SQL: ORA-00942: table or viewdoes not exist

Line: 23

Text: FROM v$process p, v$session v

 

Error: PL/SQL: SQL Statement ignored

Line: 21

Text: SELECT p.spid, v.program

 

解决办法:

grant select on sys.v_$mystat to timdba;

 

4,再次调试报错信息3

Compilation errors for TRIGGERTIMDBA.LOGON_DENIED_TO_ALERT

 

Error: PL/SQL: ORA-00942: table or viewdoes not exist

Line: 23

Text: FROM v$process p, v$session v

 

Error: PL/SQL: SQL Statement ignored

Line: 21

Text: SELECT p.spid, v.program

 

解决办法:

grant select on sys.v_$process to timdba;

grant select on sys.v_$session to timdba;

 

 

 

 

 

 

 

参考文章地址:https://blogs.oracle.com/mandalika/entry/resolving_pls_00201_identifier_dbms

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值