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=43_Update_PURGE_MEM_TXN_Part_3.sql
set SQLInput2=44_Update_PURGE_MEM_TXN_Part_4.sql
set SQLInput3=45_Update_PURGE_MEM_TXN_Part_5.sql
set SQLInput4=46_Update_PURGE_MEM_TXN_Part_6.sql
set SQLInput5=47_Update_EIM_LOY_TXN.sql
set SQLInput6=48_Update_EIM_LOY_ACRLIT.sql
set SQLInput7=49_Update_EIM_CON_DTL_Notes.sql
set SQLInput8=50_Update_PURGE_tables_UPDATED_FLG.sql
set SQLInput9=51_Update_PURGE_MEM_REDEEMABLE_Part_2.sql
set SQLInput10=52_Update_PURGE_MEM_REDEEMABLE_Part_3.sql
set SQLInput11=53_Update_PURGE_MEM_REDEEMABLE_Part_4.sql
set SQLInput12=54_Update_PURGE_MEM_REDEEMABLE_Part_5.sql
set SQLInput13=55_Update_PURGE_MEM_INFO_Part_2.sql
set SQLInput14=71_Update_PURGE_and_EIM_Tables.sql
rem     Logfile name will also be the folder name under mileageplan
set logname=71_Update_PURGE_and_EIM_Tables
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 NextSQL-5
echo *** Cannot find SQL input file4 >>%logfile%
goto ErrorExit
:NextSQL-5
if exist %inpath%\%SQLInput5% goto NextSQL-6
echo *** Cannot find SQL input file5 >>%logfile%
goto ErrorExit
:NextSQL-6
if exist %inpath%\%SQLInput6% goto NextSQL-7
echo *** Cannot find SQL input file6 >>%logfile%
goto ErrorExit
:NextSQL-7
if exist %inpath%\%SQLInput7% goto NextSQL-8
echo *** Cannot find SQL input file7 >>%logfile%
goto ErrorExit
:NextSQL-8
if exist %inpath%\%SQLInput8% goto NextSQL-9
echo *** Cannot find SQL input file8 >>%logfile%
goto ErrorExit
:NextSQL-9
if exist %inpath%\%SQLInput9% goto NextSQL-10
echo *** Cannot find SQL input file9 >>%logfile%
goto ErrorExit
:NextSQL-10
if exist %inpath%\%SQLInput10% goto NextSQL-11
echo *** Cannot find SQL input file10 >>%logfile%
goto ErrorExit
:NextSQL-11
if exist %inpath%\%SQLInput11% goto NextSQL-12
echo *** Cannot find SQL input file11 >>%logfile%
goto ErrorExit
:NextSQL-12
if exist %inpath%\%SQLInput12% goto NextSQL-13
echo *** Cannot find SQL input file12 >>%logfile%
goto ErrorExit
:NextSQL-13
if exist %inpath%\%SQLInput13% goto NextSQL-14
echo *** Cannot find SQL input file13 >>%logfile%
goto ErrorExit
:NextSQL-14
if exist %inpath%\%SQLInput14% goto SetConnect
echo *** Cannot find SQL input file14 >>%logfile%
goto ErrorExit

:SetConnect
CALL ..\shared\Solar_Connect.cmd %logfile%
if not "%errorlevel%"=="0" goto ErrorExit
rem
:Startsql
rem
sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput14% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput1% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput2% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput3% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput4% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput5% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput6% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput7% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput8% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput9% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput10% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput11% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput12% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

sqlplus -L %Uid%/%upw%@%DBConnect% @%inpath%\%SQLInput13% >>%logfile%
if not "%errorlevel%"=="0" goto ErrorExit
echo **** Process Complete **** >>%logfile%

goto exit
rem
:ErrorExit
echo **** Processing error **** >>%logfile%
echo **** Processing error ****
:EXIT


