문제

In the script below, when there is a sql error, %errorlevel% is 0 - why is this?

IF %RELEASE% GTR 2 (
    (
    echo WHENEVER SQLERROR EXIT FAILURE
    echo @release.sql
    echo exit
    ) | sqlplus x/x@orcl
    echo error: %errorlevel%
    if %errorlevel% gtr 0 goto dberror
)   

If I remove the if block (below) then %errorlevel% is NON zero! Why does the if statement affect the error level?

    (
    echo WHENEVER SQLERROR EXIT FAILURE
    echo @release.sql
    echo exit
    ) | sqlplus x/x@orcl
    echo error: %errorlevel%
    if %errorlevel% gtr 0 goto dberror

Update: Believe it was the way I was testing for an error. I think instead of:

if %errorlevel% gtr 0 goto dberror

.. should be using:

if errorlevel 1 goto dberror

Useful link here

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top