batch file - Problems with finding errors using errorlevel -


i'm having issues errors 1 af batchjobs. i'm running 50 batchjobs each day, log file, tells me if batchjob completed or not. last week i've noticed errors, , right now, don't have control shows or tells me if batchjob fails error. batchjobs starting af script via sqlplus. i've tried use errorlevel, id didn't work.

my batchjob looking far. i've included errorlevel code tried use.

@echo off @for /f "tokens=1,2,3,4 delims=-/ " %%a in ('date /t') @( set day=%%a set month=%%b set year=%%c set all=%%a-%%b-%%c ) @for /f "tokens=1,2,3 delims=:,. " %%a in ('echo %time%') @( set hour=%%a set min=%%b set sec=%%c set allm=%%a.%%b.%%c ) @for /f "tokens=3 delims=: " %%a in ('time /t ') @( set ampm=%%a @echo on ) echo start: %date% %time%    >> ..\log\scriptname_%all%_%allm%.log sqlplus "script" >> ..\log\scriptname_%all%_%allm%.log if %errorlevel% neq 0 goto :error goto :success :error echo there error. echo stop: %date% %time%    >> ..\log\scriptname_%all%_%allm%.log exit 1 :end echo success. echo stop: %date% %time%    >> ..\log\scriptname_%all%_%allm%.log exit 0 

your batch file looks fine. problem sql*plus script.

sql*plus not return error default if error occurs within sql*plus script. can use whenever sqlerror , whenever oserror within sql*plus script force termination non-zero error code upon error.

whenever sqlerror exit failure whenever oserror exit failure 

there various options better control returned code, , control transaction behavior (commit or rollback). follow links more info.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -