Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to automate a script using batch file. I have an import statement which has to run from cmd and once it is completed, I have to run ".sql" file by logging into SQLPLUS. How do I do this. I have written a batch file which runs a sequence of .sql file then I need to do the import script from cmd after it gets over,I need to run .sql file, but my batch doest not wait for import statement and it runs the other .sql files. Please help.

What I have tried:

cd "C:\Users\Karthikeyan\Downloads\install"
sqlplus / as sysdba @C:\Users\Karthikeyan\Downloads\install\m1.sql
cd "C:\Users\Karthikeyan\Downloads\Scripts"
sqlplus / as sysdba @C:\Users\Karthikeyan\Downloads\Scripts\a1.sql
sqlplus user/pass @C:\Users\Karthikeyan\Downloads\Scripts\t1.sql

Here i need to run imprt script from command prompt
cd "C:\Users\Karthikeyan\Downloads\install"
echo "enter import statement"
imp user/pass import query goes on
after importing the import statement then again it should continue the blow sql files.
pause

sqlplus m_817/mentis @C:\Users\Karthikeyan\Downloadsinstall\d1.sql
cd "C:\Users\Karthikeyan\Downloads\install"
sqlplus / as sysdba @C:\Users\Karthikeyan\Downloads\install\c1.sql
Posted
Updated 17-Sep-20 4:33am
v3

1 solution

You can use the Pause command to suspend a batch file. It will then wait for you to press enter to continue.
 
Share this answer
 
Comments
pooher 17-Sep-20 9:59am    
Thx for your reply.After pause, when i click on enter or any other button it exits out of command prompt.
Richard MacCutchan 17-Sep-20 10:14am    
Please use the Improve question link above, and add the exact script that you are using.
pooher 17-Sep-20 10:34am    
Hi Richard, I have updated the script by adding a pause.
Richard MacCutchan 17-Sep-20 11:01am    
I cannot see anything wrong there. The script should wait until you press a key and then proceed. You need to check that it is not breaking for some other reason.
pooher 17-Sep-20 10:56am    
Anyway thx Richard, I solved it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900