【问题标题】:Database Query Is not working in batch file数据库查询在批处理文件中不起作用
【发布时间】:2018-10-15 16:43:36
【问题描述】:
@echo off

set user_name=username
set password=
set sid=sid

@echo select distinct scid, to_char(dlog_on_timestamp,'dd-Mon-YYYY hh:mi:ss') from table where dlog_on_timestamp > sysdate-7; | sqlplus -s %user_name%/%password%@%sid% >> C:\Users\test.txt

在运行这个批处理文件时,> 符号创建了文件 sysdate-7。但我需要运行数据库查询,结果应该存储在 test.txt

【问题讨论】:

    标签: sql oracle batch-file sqlplus


    【解决方案1】:

    在命令周围为您的 shell (cmd.exe?) 加上引号:

    @echo "select distinct scid, to_char(dlog_on_timestamp,'dd-Mon-YYYY hh:mi:ss') from table where dlog_on_timestamp > sysdate-7;" | sqlplus -s %user_name%/%password%@%sid% >> C:\Users\test.txt
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-20
      • 1970-01-01
      • 2012-10-14
      • 2015-11-29
      • 1970-01-01
      相关资源
      最近更新 更多