检测sqlplus的错误在DOS批处理脚本? [英] Detect sqlplus error in dos batch script?

查看:175
本文介绍了检测sqlplus的错误在DOS批处理脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有以下批处理脚本:

We have the following batch script:

(
echo @release.sql
echo exit
) | sqlplus x/y@orcl

if %errorlevel% gtr 1 goto dberror

问题是 - 声明如果%ERRORLEVEL%GTR 1 从不出现时,有一个SQL错误是真实的。

Issue is - the statement if %errorlevel% gtr 1 never appears to be true when there is a sql error.

如果我们把垃圾命令在release.sql文件,sqlplus中也抱怨:

If we put garbage commands in the release.sql file, sqlplus does complain:

SQL> SP2-0042: unknown command "blah" - rest of line ignored.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

%ERRORLEVEL%还是等于0,我们如何确定,有一个SQL错误?

But %errorlevel% still equals 0. How can we determine that there was a sql error?

更新:这code确实出现了一些SQL错误工作。如果我这样做会工作删除表等等,但它不会只在命令工作等等

Update: This code DOES appear to work for some sql errors. It will work if I do drop table blah but it won't work with just the command blah

推荐答案

在看看:

WHENEVER SQLERROR

WHENEVER SQLERROR

<一个href=\"http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_twelve052.htm\">http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_twelve052.htm

WHENEVER OSERROR

WHENEVER OSERROR

<一个href=\"http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_twelve051.htm\">http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_twelve051.htm

这篇关于检测sqlplus的错误在DOS批处理脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆