[20250712]建立完善oerrz.sql脚本.txt --//重新编写oerrz.sql脚本,使用更加灵活。 --//我以前使用bash shell写的如下。 $ cat ~/bin/oerrx #! /bin/bash a=`echo $1 | cut -d"-" -f1` b=`echo $1 | cut -d"-" -f2` oerr $a $b --//需要在sqlplus查看时执行: SCOTT@book01p> host oerrx ora-1 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. --//tpt的脚本也一个查询oerr.sql的脚本,直接执行的是 exec dbms_output.put_line(sqlerrm(-&1)) --//缺点仅仅查询ora系列的错误。 --//我自己改写如下,查询其他错误也更加灵活。 $ cat oerrz.sql -- Copyright 2023 lfree. All rights reserved. -- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms and conditions. -------------------------------------------------------------------------------- -- -- File name: oerrz.sql -- Purpose: oerr functionality - list description for and ORA- or other error code -- The data comes from $ORACLE_HOME/rdbms/mesg/oraus.msb file -- which is a binary compiled version of $ORACLE_HOME/rdbms/mesg/oraus.msg file -- -- Author: lfree -- -- Usage: @ oerrz <error_code> -- @ oerrz ora-1403 -- @ oerrz 1403 -- default ora- error -------------------------------------------------------------------------------- column error_s new_value error_s column error_n new_value error_n set term off select nvl(substr('&1',1,instr('&&1','-')-1),'ora') error_s,substr('&1',instr('&&1','-')+1) error_n from dual ; set term on prompt host oerr &error_s &error_n --//测试例子: SYS@book> @ oerrz 1 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. SYS@book> @ oerrz ora-1403 01403, 00000, "no data found" // *Cause: No data was found from the objects. // *Action: There was no data from the objects which may be due to end of fetch. SYS@book> @ oerrz tns-12560 12560, 00000, "TNS:protocol adapter error" // *Cause: A generic protocol adapter error occurred. // *Action: Check addresses used for proper protocol specification. Before // reporting this error, look at the error stack and check for lower level // transport errors. For further details, turn on tracing and reexecute the // operation. Turn off tracing when the operation is complete. --//顺便修改oerrx的bash shell脚本为oerrz: $ cat oerrz #! /bin/bash pos=$(expr index $1 "-") len=${#1} if [[ $pos == 0 ]];then a=ora b=$1 else #a=$(expr substr "$1" 1 $(( pos -1 ))) #b=$(expr substr "$1" $(( pos +1 )) $len ) a=${1:0: $(( pos -1 ))} b=${1:$(( pos ))} fi echo oerr $a $b echo
[20250712]建立完善oerrz.sql脚本.txt
来源:这里教程网
时间:2026-03-03 22:20:10
作者:
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 第44期 使用什么命令能删除 FOREIGN ARCHIVED LOG
第44期 使用什么命令能删除 FOREIGN ARCHIVED LOG
26-03-03 - 比格比萨,怎么成了披萨界的“穷鬼自助”顶流?
比格比萨,怎么成了披萨界的“穷鬼自助”顶流?
26-03-03 - 保险业加速向外资开放,险企入华前景几何?
保险业加速向外资开放,险企入华前景几何?
26-03-03 - YU7不便宜,为什么还让人觉得“赚到了”?
YU7不便宜,为什么还让人觉得“赚到了”?
26-03-03 - Oracle连接问题排查实录:TNSPING跟踪在定位故障中的实战应用
Oracle连接问题排查实录:TNSPING跟踪在定位故障中的实战应用
26-03-03 - oracle 23ai通过接口访问deepseek模型
oracle 23ai通过接口访问deepseek模型
26-03-03 - 一招解锁:快速解决Oracle ORA-38029错误
一招解锁:快速解决Oracle ORA-38029错误
26-03-03 - 雨花用诚意写下“背包客创业指南”!
雨花用诚意写下“背包客创业指南”!
26-03-03 - 谁在为三块钱的冰杯买单?
谁在为三块钱的冰杯买单?
26-03-03 - Oracle LibCache等待优化(一)
Oracle LibCache等待优化(一)
26-03-03
