SQLPLUS command line with Windows batch file

只愿长相守 提交于 2019-11-29 10:43:25

What about native Sql*plus spooling?

run.bat:

sqlplus hr/hr@sandbox @d:\run.sql

run.sql:

spool d:\run.log
set echo on 

select * from dual
/
exit

run.log:

01:50:20 HR@sandbox> 
01:50:20 HR@sandbox> select * from dual
01:50:20   2  /

D
-
X

Elapsed: 00:00:00.00
01:50:21 HR@sandbox> exit
SET ORACLE_SID=<YOUR SID HERE>

sqlplus scott/tiger@DB < sql1.sql > data1.txt
sqlplus scott/tiger@DB < sql2.sql > data2.txt
Roland

For your information, and for the rest of the community, I was using this command line in a dos file :

sqlplus.exe SIEBEL/mypass@mydb @D:\App\Siebel\EIM\sql\my_sql_command.sql

and the output was :

SQL*Plus: Release 11.2.0.1.0 Production on Mar. Sept. 13 11:53:52 2016

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS : .....

in fact, I had an error in the command line ....

sqlplus.exe SIEBEL/mypass@mydb**%** @D:\App\Siebel\EIM\sql\my_sql_command.sql
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!