程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> ORACLE 11G 觸發器調試記錄Error: PLS-00201: identifier'SYS.DBMS_SYSTEM' must be declared

ORACLE 11G 觸發器調試記錄Error: PLS-00201: identifier'SYS.DBMS_SYSTEM' must be declared

編輯:Oracle教程

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;

 

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;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved