|
Answer» I am new to batch file and can not figure out how to execute a sql statement in oracle and then OPEN the .txt file that is generated as result.
here is the first code, and it works great.
File Name: CRA_test1.bat
C:\ora8i\bin\sqlplusw.exe [email protected]/password1 c:\temp\CRA_data_test.sql
the query will run and it is designed to generate a text file called CRA_data.txt in the c:\temp\ FOLDER and it does the job.
then when I click on the 2nd file it works as well.
File Name: CRA_test2.bat
START IF EXIST C:\temp\CRA_data.txt START C:\WINNT\system32\notepad.exe C:\temp\CRA_data.txt
this would open the text file if it exist (basically careated by the first batch file).
what my problem is try to combine both of this in one batch file.
this way I can PUT a batch file short cut on the user's pc and when they click on it it would run the query and then open up the notepad.
I have tried PAUSE which I hoped would run the query and then wait and then allow the user to presss any key to continue to the second process...but it just closes after the query.
C:\ora8i\bin\sqlplusw.exe [email protected]/password1 c:\temp\CRA_data_test.sql PAUSE START IF EXIST C:\temp\CRA_data.txt START C:\WINNT\system32\notepad.exe C:\temp\CRA_data.txt
I tried /wait but that didn't do any help either.
C:\ora8i\bin\sqlplusw.exe [email protected]/password1 c:\temp\CRA_data_test.sql /wait START IF EXIST C:\temp\CRA_data.txt START C:\WINNT\system32\notepad.exe C:\temp\CRA_data.txt
I tried SLEEP but that didn't do anything either.....had chosen 20 seconds and 30 seconds which was plenty of TIME for the query to run.
C:\ora8i\bin\sqlplusw.exe [email protected]/password1 c:\temp\CRA_data_test.sql SLEEP 30 START IF EXIST C:\temp\CRA_data.txt START C:\WINNT\system32\notepad.exe C:\temp\CRA_data.txt
any suggestions or guidence will be greatly appreciated.
thank you.
desaidesai, you should do a little "debugging". Let those 2 batch files. Make a third batch file, in which write:
call CRA_test1.bat > bat_output.txt pause call CRA_test2.bat >> bat_output.txt
After you run that 3 bat file, see what is written in bat_output.txt. We wait your reply. thank you for the help.
It did the trick.
only thing is now that the dos cmd prompt still displays .... and user would have to manually type 'exit' and click 'enter' key to close it or click on the 'x' on the upper right hand side of the frame to close it.
is there a way to automatically close that dos prompt that is popped up once the txt file is opened in notepad....without closing the txt file.
thanks again.
|