hiFI
hiFI

Reputation: 1961

Oracle Script File Execution in *.bat file not completing

I have the following *.bat file executing itself on a schedule. This file consists of different tasks, primarily involves in having a the backup dump file exported to the Test DB Machine every day.

@echo off
@echo %time%
del C:\Factory\index.sql
echo exporting indexes...
Imp jksbschema/password file=C:\DBDUMP\jksb.dmp full=yes log=C:\Factory\log\dump_index.log indexfile=index.sql
@echo %time%
echo connecting to Oracle...
echo Delete and Re-Creation of User
sqlplus "sys/password as sysdba" @C:\Factory\script\step_1.sql
echo importing dump file begins...
@echo %time%
Imp jksbschema/password file=C:\DBDUMP\jksb.dmp full=yes log=C:\Factory\log\dump.log Compile=n INDEXES=n
echo Applying security priviledges
@echo %time%
sqlplus "sys/password as sysdba" @C:\Factory\script\step_2.sql
@echo %time%
ssr 0 "CONNECT" "REM CONNECT" C:\Factory\index.sql
echo Loading Indexes....`enter code here`
sqlplus "jksbschema/password as sysdba" @C:\Factory\index.sql
@echo %time%
exit
shutdown.exe -r -t 00

Since its a long operation, I execute itself on every night, expecting it to be ready next morning. I also include a command restart the machine once the entire process is over. All the command finishes without asking an input expect the following command:

sqlplus "jksbschema/password as sysdba" @C:\Factory\index.sql

after the above command executes, the batch file asks for an input to exit the process as the snapshot below says

enter image description here

Can anybody help in automatically finish the job and restart itself, rather than ask for an input after the index.sql file is loaded?

Upvotes: 1

Views: 2265

Answers (2)

Christian Gosch
Christian Gosch

Reputation: 75

Old stuff, but however: Let "exit;" be the last command of your SQL script. This tells sqlplus to quit and finish execution.

Upvotes: 0

Rocklan
Rocklan

Reputation: 8130

Create a file named quit.txt, inside it put the text "quit".

Where you see the lines that execute sqlplus, like this one:

sqlplus "jksbschema/password as sysdba" @C:\Factory\index.sql

change them to this:

sqlplus "jksbschema/password as sysdba" @C:\Factory\index.sql < quit.txt

Upvotes: 3

Related Questions