prompting multiple db password for sql scripts

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Aks_dolly
Posts: 1
Joined: 01 Jun 2021 05:41

prompting multiple db password for sql scripts

#1 Post by Aks_dolly » 01 Jun 2021 06:02

Hello, I am newbie in windows batch file. I developed a batch file to execute oracle sql scripts. Batch file will run those sql scripts based on the month.Some of them needs to be executed bi annually and quarterly. Bat file does work but issue I am facing is its prompting for database password for each of the scripts. I am looking for a way such that I should be providing the database password once when I start the batch file along with the batch file name. batch file will be running in client machine, we don't have to mask the password. Please let me know what am I missing and help me on this. Thank you in advance.

Code: Select all

Set TODAYSDATE=%date:~4,2%%date:~7,2%%date:~10,4%

echo on

SET REPDATE=%TODAYSDATE%

Set CURYEAR=%date:~10,4%

for /f "tokens=1-4 delims=/- " %%a in ('date /t') do set month_num=%%b
 
if %month_num% == 01 set qrtr_var=Q1
if %month_num% == 02 set qrtr_var=Q1
if %month_num% == 03 set qrtr_var=Q1
if %month_num% == 04 set qrtr_var=Q2
if %month_num% == 05 set qrtr_var=Q2
if %month_num% == 06 set qrtr_var=Q2
if %month_num% == 07 set qrtr_var=Q3
if %month_num% == 08 set qrtr_var=Q3
if %month_num% == 09 set qrtr_var=Q3
if %month_num% == 10 set qrtr_var=Q4
if %month_num% == 11 set qrtr_var=Q4
if %month_num% == 12 set qrtr_var=Q4

if %month_num% == 01 set G=JAN
if %month_num% == 02 set G=FEB
if %month_num% == 03 set G=MAR
if %month_num% == 04 set G=APR
if %month_num% == 05 set G=MAY
if %month_num% == 06 set G=JUN
if %month_num% == 07 set G=JUL
if %month_num% == 08 set G=AUG
if %month_num% == 09 set G=SEP
if %month_num% == 10 set G=OCT
if %month_num% == 11 set G=NOV
if %month_num% == 12 set G=DEC


SET "LIST=JAN,JUL"
SET "LIST2=JAN,MAY,JUL,OCT"
FOR %%A IN (%LIST%) DO (IF "%G%"=="%%A" (CALL :COND1) ELSE CALL :COND3)
FOR %%C IN (%LIST2%) DO (IF "%G%"=="%%C" (CALL :COND2) ELSE CALL :COND3)
EXIT/B

:COND1
@ECHO ON
REM ###########	Report name1	  #####################################################
sqlplus %username%@dbname/%1 @"clearcase path"
copy C:\Developers\1reportname_%TODAYSDATE%.xls    "shared drive link to copy " 

REM ###########	Report name2	  #####################################################
sqlplus %username%@dbname/%1 @"clearcase path"
copy C:\Developers\1reportname_%TODAYSDATE%.xls    "shared drive link to copy " 

REM ###########	Report name2	  #####################################################
sqlplus %username%@dbname/%1 @"clearcase path"
copy C:\Developers\1reportname_%TODAYSDATE%.xls    "shared drive link to copy " 

GOTO :EOF

:COND2
@ECHO ON
REM ###########	Report name4	  #####################################################
sqlplus %username%@dbname/%1 @"clearcase path"
copy C:\Developers\1reportname_%TODAYSDATE%.xls    "shared drive link to copy " 

REM ###########	Report name5	  #####################################################
sqlplus %username%@dbname/%1 @"clearcase path"
copy C:\Developers\1reportname_%TODAYSDATE%.xls    "shared drive link to copy " 

REM ###########	Report name6	  #####################################################
sqlplus %username%@dbname/%1 @"clearcase path"
copy C:\Developers\1reportname_%TODAYSDATE%.xls    "shared drive link to copy " 
ECHO "REPORTS GENERATED AND FILES COPIED TO SHARED DRIVE"
GOTO :EOF

:COND3
GOTO :EOF

Post Reply