Saturday 05 May, 2007 - 12:51pm | 5
To run multiple SQLPlus queries as part of a DOS batch file place all the
queries in a separate SQL file. For Example
Save the file as runall.sql. Then use this file in your batch file
sqlplus [login details] @C:\queries\runall.sql
That was exactly what I was looking for and it works like a charm, many thanks.
you can try this under Unix it works :
echo exit | sqlplus .... @my.file.sql
ADD EXIT AFTER ALL THE @...SQL FILES HAVE BEEN LISTED IN RUNALL.SQL FILE.
Hmmmm -I've used this commercially without problem. Individual queries cycle through until complete, the only exit I invoke is at the end of the combined SQL file to close the SQL*Plus window and allow the batch file to continue with any other commands such as file moving, renaming etc etc. It really has been that simple.....
Otherwise you will be exiting SQL*Plus after each query has executed, you will then need to log back into it again for each query to run. Once you open SQL*Plus it will keep looping through your queries until it comes to an end. One SQL query finishes, another begins. You don't need to exit and then log back in again for that to happen. You only need to do that at the end.
You also need to ensure that each sql script being called has an exit statement, else the batch file halts waiting for user intervention....