SQLPLUS command line with Windows batch file

前端 未结 3 1802
我在风中等你
我在风中等你 2020-12-19 05:26

I want to create a batch file which will open the SQLPLUS [CLI] and will execute some stored sql file and will also store the output to text file.

So I\'ve created t

相关标签:
3条回答
  • 2020-12-19 06:09

    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
    
    0 讨论(0)
  • 2020-12-19 06:23
    SET ORACLE_SID=<YOUR SID HERE>
    
    sqlplus scott/tiger@DB < sql1.sql > data1.txt
    sqlplus scott/tiger@DB < sql2.sql > data2.txt
    
    0 讨论(0)
  • 2020-12-19 06:26

    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
    
    0 讨论(0)
提交回复
热议问题