0
我们试图通过在批处理文件中调用一个SQL文件来创建一个输出文件(SQL.txt),它成功了,然后尝试从输出文件中的特定行分配特定值(SQL。 txt)使用FOR/f命令给变量,并基于此我们尝试将IF条件与变量值进行比较。事情是当我们回顾变量值时,它显示的价值,也显示下面的行。因此,IF条件不起作用。使用SQL输出的批处理脚本
详情请参阅下面的查询。
1) call sqlplus username/[email protected] @D:\SQL\REORG_DATA.sql >D:\SQL\SQL_OUTPUT\output.txt
2) for /f "skip=14 delims=5" %%n in (D:\SQL\SQL_OUTPUT\output.txt) do echo %%n
3) if %%n EQU 0 goto ErrExit
我的输出文件始终下同输出文件信息
我们想捕捉0(零)值到IF条件作为变量值(%% N),它总是15号线和6 dlims
1
2 SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 23 14:17:56 2015
3
4 Copyright (c) 1982, 2010, Oracle. All rights reserved.
5
6
7 Connected to:
8 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
9 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
10 Data Mining and Real Application Testing options
11
12
13 COUNT(*)
14 ----------
15 0
16
17 Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
18 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
19 Data Mining and Real Application Testing options
20
请帮助。
问候 纳格
由于包括样品供你参考,如你所说的我跟随,也试图把GOTO命令从循环退出,但它仍然是重新分配剩余的行来计数变量,我需要确切的单行值,你可以告诉如何分配单个值后,如何把goto命令。在(D:\ SLB \ APP \ Hyperion \ Automations \ SQL \ SQL_OUTPUT \ output.txt)中为/ f“skip = 14”%% n设置“count =” do gotof eof“count = %% n” 回声%count%我已经使用上面的代码离开循环。 – NAG 2015-02-24 12:52:02
@NAG,回答更新以包含代码与'goto' – 2015-02-24 12:58:05
我建议,如果15行的值总是数字,'set/a count = %% n'会更可取。 – Magoo 2015-02-24 13:54:09