且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[20151210]oerr显示错误信息.txt

更新时间:2022-09-10 16:19:35

[20151210]oerr显示错误信息.txt

--以前写过1篇windows下使用oerr的方法,实际上12c已经自带,我现在使用client端是12c,但是没有oraus.msg文件,从别的os 拷贝过
--来就可以使用。可以参考我的链接:
http://blog.itpub.net/267265/viewspace-1251067/

不过我总觉的oracle 不够智能,应该直接输入
oerr ora-00001 就可以查看错误。自己顺手写一个小脚本:

$ cat /usr/local/bin/oerrx
#! /bin/bash

a=`echo $1 | cut -d"-" -f1`
b=`echo $1 | cut -d"-" -f2`
echo ''
oerr $a $b
echo ''


$ oerrx ora-00001

00001, 00000, "unique constraint (%s.%s) violated"
// *Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.
//         For Trusted Oracle configured in DBMS MAC mode, you may see
//         this message if a duplicate entry exists at a different level.
// *Action: Either remove the unique restriction or do not insert the key.

--这样就可以直接查询了。

--我还建立sql脚本:
$ cat oerrx.sql
host oerrx &&1

--这样sqlplus下直接输入 @ oerrx ora-0001 就可以了。

--如果windows的服务器,没有oerr的命令,可以自己写一个脚本,内容如下:

$ cat oerr.sql
prompt
SET serveroutput ON SIZE 1000000
SET feedback off
EXEC dbms_output.put_line('Error ' || &&1 || ' is : ' ||sqlerrm(-1 * &&1));
prompt
undefine 1
SET feedback ON

--缺点是提示太简单。没有后面的相关信息。