call ..\shared\SetVariables.cmd
@echo off
rem this command will logon to a database based on the AIRGROUP_DEPLOY_TYPE
rem using the userid and password defined in uid and pwd
rem 
rem -----------------------------------------------------------------
rem     Define script variables. 
rem     Path where the SQL script lives
set inpath=%CD%
rem     Name of the script. Script must end with the word Quit to exit the SQLPlus processor
set SQLInput1=74_Update_S_LOY_RDM_ITM_Task1.sql
set SQLInput2=74_Update_S_LOY_RDM_ITM_Task2.sql
set SQLInput3=74_Update_S_LOY_RDM_ITM_Task3.sql
set SQLInput4=74_Update_S_LOY_RDM_ITM_Task4.sql
rem     Logfile name will also be the folder name under mileageplan
set logname=74_Update_S_LOY_RDM_ITM
set uid=%SOLAR_SIEBEL_PURGE_UID%
set upw=%SOLAR_SIEBEL_PURGE_PWD%
rem -----------------------------------------------------------------
rem 
rem Get current date and time and append to logfile name
rem
for /F "tokens=2-4 delims=/ " %%v in ('date /T') do (set cdate=%%x%%v%%w)
for /F "tokens=1-3 delims=:." %%v in ('echo %time%') do (set ctime=%%v%%w%%x)
rem
rem
set logpath=%AIRGROUP_LOG_ROOT%\MileagePlan\TransactionPurge\%logname%
rem
if not exist %logpath%\*.* md %logpath%
rem
set logfile=%logpath%\%logname%-%cdate%%ctime%.log
rem 
rem
echo **** Begin process **** >%logfile%
if exist %inpath%\%SQLInput1% goto NextSQL-2
echo *** Cannot find SQL input file1 >>%logfile%
goto ErrorExit
:NextSQL-2
if exist %inpath%\%SQLInput2% goto NextSQL-3
echo *** Cannot find SQL input file2 >>%logfile%
goto ErrorExit
:NextSQL-3
if exist %inpath%\%SQLInput3% goto NextSQL-4
echo *** Cannot find SQL input file3 >>%logfile%
goto ErrorExit
:NextSQL-4
if exist %inpath%\%SQLInput4% goto SetConnect
echo *** Cannot find SQL input file4 >>%logfile%
goto ErrorExit

:SetConnect
CALL ..\shared\Solar_Connect.cmd %logfile%
if not "%errorlevel%"=="0" goto ErrorExit
rem
:Startsql
rem
start sqlplus -S %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput1%
timeout 5
start sqlplus -S %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput2%
timeout 5
start sqlplus -S %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput3%
timeout 5
start sqlplus -S %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput4%

if not "%errorlevel%"=="0" goto ErrorExit
echo **** Parallel tasks are started **** >>%logfile%
goto exit
rem
:ErrorExit
echo **** Processing error **** >>%logfile%
echo **** Processing error ****
:EXIT


