|
-
March 5th, 2010, 02:01 AM
#1
Batch script
I am newbee....
I have following batch script that do some updates on the database.I need to run this batch file which should run each OSQL command.All the OSQL command should run .If any of the OSQL commands gets error out the script should return the error level else it should return 0.
This script is not retuning the error level as required .Also :GOTERROR is not getting called.
Any help should be appreciated.
Code:
echo ON
setlocal
set errcode=0
set /A Counter=0
ECHO now updating config value for the settlements >> F:\log\Config_update.log
osql -SSERVER1-dDATABASE1 -E -e -b -Q "Update app_config set config_value = (SELECT config_value FROM app_config WHERE config_key = 'Config.LastFileCreationNumber' AND app_code = 97) where config_key = 'Config.LastFileCreationNumber' AND app_code = 47;" >> F:\log\Config_update.log
SET VarSettle=MonerisSettlement
IF ERRORLEVEL 1 (
set /A Counter+=1
CALL :GOTERROR
) else (
call :PROCESSED
)
osql -SSERVER1-dDATABASE1 -E -e -b -Q "Update app_config set config_value = (SELECT config_value FROM app_config WHERE config_key = 'Config.FileSequenceNumber' AND app_code = 120) where config_key = 'Config.FileSequenceNumber' AND app_code = 121;" >> F:\log\Config_update.log
SET VarSettle=AmexCapnCanadaSettlemenT
IF ERRORLEVEL 1 (
set /A Counter+=1
CALL :GOTERROR
) else (
call :PROCESSED
)
osql -SSERVER1-dDATABASE1 -E -e -b -Q "Update app_config set config_value = (SELECT config_value FROM app_config WHERE config_key = 'Config.FileSequenceNumber' AND app_code = 66) where config_key = 'Config.FileSequenceNumber' AND app_code = 17;" >> F:\log\Config_update.log
SET VarSettle=AmexEmeaSettlement Config.FileSequenceNumber
IF ERRORLEVEL 1 (
set /A Counter+=1
CALL :GOTERROR
) else (
call :PROCESSED
)
osql -SSERVER1-dDATABASE1 -E -e -b -Q "Update app_config set config_value = (SELECT config_value FROM app_config WHERE config_key = 'Config.VolumeIdentifierCounter' AND app_code = 66) where config_key = 'Config.VolumeIdentifierCounter' AND app_code = 17;" >> F:\log\Config_update.log
SET VarSettle=AmexEmeaSettlement Config.VolumeIdentifierCounte
IF ERRORLEVEL 1 (
set /A Counter+=1
CALL :GOTERROR
) else (
call :PROCESSED
)
osql -SSERVER1-dDATABASE1 -E -e -b -Q "Update app_config set config_value = (SELECT config_value FROM app_config WHERE config_key = 'Config.FileSequenceNumber' AND app_code = 107) where config_key = 'Config.FileSequenceNumber' AND app_code = 104;" >> F:\log\Config_update.log
SET VarSettle=AmexCapnSettlements
IF ERRORLEVEL 1 (
set /A Counter+=1
CALL :GOTERROR
) else (
call :PROCESSED
)
osql -SSERVER1-dDATABASE1 -E -e -b -Q "Update app_config set config_value = (SELECT config_value FROM app_config WHERE config_key = 'Config.VolumeIdentifierCounter' AND app_code = 96) where config_key = 'Config.VolumeIdentifierCounter' AND app_code = 46;" >> F:\log\Config_update.log
SET VarSettle=SettlementBarclays
IF ERRORLEVEL 1 (
set /A Counter+=1
CALL :GOTERROR
) else (
call :PROCESSED
)
GOTO END
:PROCESSED
ECHO %VarSettle% Processed OK >> F:\log\Config_update.log
GOTO :EOF
:GOTERROR
ECHO Error Encountered in updating %VarSettle% with error level %ERRORLEVEL% >> F:\log\Config_update.log
goto :EOF
:END
ECHO End Of Updating Config Value >> F:\log\Config_update.log
if %Counter% EQU 0 (RET=0) else (RET=1)
echo %RET%
endlocal
Last edited by PeejAvery; March 5th, 2010 at 04:43 PM.
Reason: Added code tags.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|