We need a Script which can execute multiple sql scripts in sqlplus RRS feed

  • Question

  • Hello,

    We need a script which can execute multiple sql scripts in sequential order. The script should go and execute the script1.sql first and wait for this to complete and then execute the second sql script. we created a bat file for this task, but unfortunately the .bat file is not waiting for the task to complete. It is executing all the task simultaneously. I have given the bat file below. Can anyone help on this ?

    "@echo off
    echo This program loads Data from SQL1 and SQL2 to ORACLE3
    set WRKDIR=D:\Script\Test
    echo Test Running SQLPLUS
    start /wait /b D:\oracle\product\11.2.0\client_1\BIN\sqlplus userid/password@SID @%WRKDIR%\Script1.sql
    rem Clear ORA Tables
    rem start /wait /b D:\oracle\product\11.2.0\client_1\BIN\sqlplus userid/password@SID @%WRKDIR%\Script2.sql > Script2.txt
    echo Cleaning up Oracle staging data
    rem start /wait /b D:\oracle\product\11.2.0\client_1\BIN\sqlplus userid/password@SID @%WRKDIR%\Script3.sql
    echo Data load has completed. 
    exit "

    • Moved by Bill_Stewart Monday, October 27, 2014 10:08 PM Unanswerable drive-by question
    Thursday, August 21, 2014 8:31 AM

All replies

  • START /wait - waits for the program to finish.

    Most of your lines are commented out.  Remove the REM statements.

    I would create a single SQL script that calls the other three.  Do not use a batch file in  this case.


    Thursday, August 21, 2014 8:48 AM