【问题标题】:cmd script with sqlplus not returning any results带有 sqlplus 的 cmd 脚本不返回任何结果
【发布时间】:2013-04-19 19:11:56
【问题描述】:

我的 cmd 脚本现在看起来像这样:

for /f "delims=" %%a in ('sqlplus user/pass@OMP1 @CheckRowCount.SQL') do set rowcount=%%a
if %ROWCOUNT% GTR 0 (
c:\Autobatch\Spotfire.Dxp.Automation.ClientJobSender.exe     http://server/spotfireautomation/JobExecutor.asmx c:\AutoBatch\backup\Trigger_Test.xml
)EXIT

我知道

'sqlplus user/pass@omp1 @checkrowcount.sql'

之所以有效,是因为当我单独运行它时,我确实在 sqlplus 中获得了一个行数。

c:\Autobatch\Spotfire.Dxp.Automation.ClientJobSender.exe     http://server/spotfireautomation/JobExecutor.asmx c:\AutoBatch\backup\Trigger_Test.xml

在 CMD 中单独运行时也同样有效。

我想要做的是,如果 sqlplus 命令返回 > 0 的行数,则运行另一个命令。否则退出...似乎无法将它们串在一起工作。

【问题讨论】:

  • 有什么问题?您是否收到错误消息或意外结果?

标签: batch-file cmd sqlplus


【解决方案1】:

从代码 sn-p 中添加最上面的两行,看看 %rowcount% 被设置为什么。

echo "%ROWCOUNT%"
pause
if %ROWCOUNT% GTR 0 (

您可能会发现您的 sqlplus 命令在末尾返回一个空行,并且 rowcount 被设置为空。在这种情况下,这应该可以工作:

for /f "delims=" %%a in ('sqlplus user/pass@OMP1 @CheckRowCount.SQL ^|findstr "[0-9]" ') do set rowcount=%%a

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-16
    • 2017-12-28
    • 2017-12-09
    • 2020-10-03
    • 2017-03-19
    • 2017-05-20
    相关资源
    最近更新 更多