首页 > 代码库 > 使用errorstack跟踪ORA-01438 和 ORA-01031错误

使用errorstack跟踪ORA-01438 和 ORA-01031错误

设置ErrorStack主要有4个级别:
0 仅转储错误堆栈(0级已经被废弃)
1 转储错误堆栈和函数调用堆栈
2 Level 1 + ProcessState
3 Level 2 + Context area(显示所有cursors,着重显示当前cursor)
ErrorStack可以在实例级或会话级别设置,也可以在参数文件中设置,这个设置仅当某个特定的错误出现时才被触发

客户系统出现如下ORA-01438错误,提示数据的精度超过允许值,是后台Job调度的任务:
Mon Jul 13 10:27:31 2009
Errors in file /admin/erpdb/bdump/erpdb1_j000_447020.trc:
ORA-12012: error on auto execute of job 22
ORA-01438: value larger than specified precision allowed for this column
ORA-06512: at "ERP.TIMRDU", line 13
ORA-06512: at line 1
跟踪文件中缺省的不会记录具体的SQL、绑定变量等信息,我们可以通过ErrorStack进行后台跟踪,获得更详细的信息,执行如下SQL:
alter system set events=‘1438 trace name errorstack forever,level 10‘;
然后可以手工执行以下存储过程,获得跟踪文件,再关闭跟踪:
alter system set events=‘1438 trace name errorstack off‘;
在Oracle 10g中,这样的操作会被记录到日志文件中:
Mon Jul 13 10:48:39 2009
OS Pid: 541528 executed alter system set events ‘1438 trace name Errorstack forever,level 10‘
Mon Jul 13 10:56:06 2009
Errors in file /admin/erpdb/udump/erpdb1_ora_267056.trc:
ORA-01438: value larger than specified precision allowed for this column
Mon Jul 13 10:56:08 2009
Trace dumping is performing id=[cdmp_20090713105608]
Mon Jul 13 10:57:15 2009
OS Pid: 541528 executed alter system set events ‘1438 trace name Errorstack off‘
接下来分析获得的跟踪文件,就可以获得SQL文本线索,找到根本问题。
 
ITPUB上有一则极为经典详细的分析: http://www.itpub.net/thread-956435-1-1.html
 
 
在oracle管理中常碰到一些只见错误,但不知道原因的情况,如何知道是什么原因引起的错误呢。
可以用以下方法来找到原因

oracle@jpdw:/backup/>
exp system/ROBCXqRVuGLUe9Ep file=/backup/oradata/rman/hketc.dmp DIRECT=y  owner=hketc
Export: Release 10.2.0.4.0 - Production on Wed Jan 5 12:09:55 2011

Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and UTF8 NCHAR character set
server uses UTF8 character set (possible charset conversion)
  
About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user HKETC
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user HKETC
About to export HKETC‘s objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
EXP-00056: ORACLE error 1031 encountered
ORA-01031: insufficient privileges
EXP-00000: Export terminated unsuccessfully

这是在oracle 10G下的exp的一个错误,只能看到1031,但不知道是哪里出的1031
 
这时可以在sqlplus 里运行

alter system set events ‘1031 trace name errorstack level 3‘;
开启对1031的trace
然后再执行一次exp
转到udump下看产生的trc文件,里面有一段
ksedmp: internal or fatal error
ORA-01031: insufficient privileges
Current SQL statement for this session:
SELECT URL, LOCAL, STRIPPED_VAL      FROM SYS.KU$_XMLSCHEMA_VIEW      WHERE OWNER_NAME = :OWNER

问题产生的原因就是因为上面这句sql.





来自为知笔记(Wiz)


使用errorstack跟踪ORA-01438 和 ORA-01031错误