2013-05-07 53 views
6

我想創建一個批處理文件,它將打開SQLPLUS [CLI]並執行一些存儲的sql文件,並將輸出存儲到文本文件中。帶有Windows批處理文件的SQLPLUS命令行

所以我創建了這個批處理文件[不起作用]。
這些SQL文件包含SQL,它從表中返回最大數字。

sqlplus scott/[email protected] 
@sql1.sql>data1.txt 
@sql2.sql>data2.txt 

問題是,它打開SQLPLUS

  • 的Windows XP
  • 的Oracle 9i中

回答

2
SET ORACLE_SID=<YOUR SID HERE> 

sqlplus scott/[email protected] <sql1.sql> data1.txt 
sqlplus scott/[email protected] <sql2.sql> data2.txt 
+0

SID代表什麼嗎? :/ – Sourav 2013-05-07 06:12:26

+0

[ORACLE_SID](http://www.orafaq.com/wiki/ORACLE_SID)。如果系統上有一個實例,則可以跳過此行。 – valex 2013-05-07 06:48:56

+0

哎呀,沒有工作。只啓動SQLPLUS,但未能通過參數! – Sourav 2013-05-08 14:41:36

1

爲了您的信息,併爲社會的休息,我在DOS文件中使用這個命令行:

sqlplus.exe SIEBEL/[email protected] @D:\App\Siebel\EIM\sql\my_sql_command.sql 

輸出功率爲:

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 : ..... 

其實,我在命令行中的錯誤....

sqlplus.exe SIEBEL/[email protected]**%** @D:\App\Siebel\EIM\sql\my_sql_command.sql