Skip to content
Advertisement

Can’t run two .sql in a single .bat file

I have a scheduled task with a .bat file that downloads some files from a web server every day by the morning then process the data and UPDATES a database. Then it triggers another .bat file to SELECT data and EXPORT to a .xls file.

The second .bat file is like this:

But when I arrive at the office and check the progress, only the first .xls is done. So I have to run the second .bat manually and it runs perfectly.

What could be causing this?

Notes:

  1. I put the timeout between the two SELECTs because, in the past, the code was stopping after the INSERT and didn’t trigger the second .bat . My colleague said it could be execution exception. Puting a timeout would give time to end the INSERT properly.
  2. Before, it used to make both SELECTs and then rename both files. Doing so, sometimes it worked, sometimes not, then I tried to change the order: select1, rename1, select2, rename2.
  3. As we download files everyday, we concatenate the data on a single file called DT-date. The first code goes like this:
  1. As @William Robertson said, I tried echo exit right after the first SELECT, but again, it only extracted the first file and not the second one.

Advertisement

Answer

As @WilliamRobertson suggested, writing echo exit | before the sqlplus commands solved the problem.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement