|
LOGDIR=[log路徑] # 可接受的錯誤碼清單 ACCEPTABLE_ERRORS=( "ORA-31684" # Object already exists "ORA-39151" # Object skipped due to insufficient privileges "ORA-39082" # Created with compilation warnings "ORA-39083" # Object creation failed but will be skipped "ORA-01917" # User does not exist "ORA-01430" # Cannot create object, already exists "ORA-06512" # PL/SQL stack trace (usually not critical) "ORA-00955" # Name is already used by an existing object "ORA-00942" # Table or view does not exist (depends on context) "ORA-39111" # Dependent object skipped due to existing base object "ORA-39112" # Dependent object skipped because base object creation failed "ORA-39121" # Object was not imported due to already existing object with same name "ORA-32417" # Materialized view log does not exist or is incomplete ) is_acceptable_error=true # 從 log 中找出所有 ORA 錯誤碼 error_codes=$(grep -o
"ORA-[0-9]\{5\}" "${LOGDIR} " | sort | uniq) for code in $error_codes; do
found=false
for acceptable in "${ACCEPTABLE_ERRORS[@]}"; do
if [ "$code" == "$acceptable" ]; then found=true break
fi
done
if [ "$found" = false ]; then
is_acceptable_error=false
break
fi done # 根據錯誤碼與返回碼判斷是否成功 if [ $EXIT_CODE -ne 0 ]; then
if [ "$is_acceptable_error" = true ]; then
echo "[log]發現僅有可接受錯誤,視為成功。"
else
echo "[err]發生不可接受錯誤,返回碼 $EXIT_CODE,請檢查 log。"
fi fi |
2025年10月20日 星期一
[Oracle]檢查impdp的log時忽略常見錯誤
impdp常常出現報錯,但是經常是屬於可忽略的錯誤,
因此增加判斷避免每日都需要去檢查log。
用grep把所有ORA-[五碼數字]的字都抓出來,
然後用For迴圈一個一個比對錯誤碼清單,如果在清單中就found=true,不在清單中就found=false
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言