Problem in connecting to sqlplus from windows batch file (DOS)
611496Jun 22 2009 — edited Jun 22 2009Hi All,
We have a new 10g Oracle database installed on windows server. I am trying to write a windows batch file to
1) Connect to SQLPLUS
2) Execute a script
3) Disconnect from SQLPLUS.
-----------------------------------------------------------------------------------
Example File Name:- execsql.bat
SET ORACLE_SID=CAUT
SET SCHEMA_IN=%1
SET PASS=DEV
SET script=%2
sqlplus %SCHEMA_IN%/%PASS%@%ORACLE_SID% @%script%
if %errorlevel% NEQ 0 echo ERROR: %ERRORLEVEL% else echo OK
------------------------------------------------------------------------------------------------
Now if i run this bat file like :- execsql.bat DEV script1.sql
DEV= schema name,
script1.sql = this file contains select * from dual;
The code runs fine, but if i change dual to dual1 the sql error's out but not able to catch the error in the batch file.
Reason why i would like to catch the error is this batch file would be scheduled through Autosys job scheduler and for autosys any exit code >0 is an error. Please help me in rewriting this batch script.
Thanks
Sam.