【发布时间】:2019-03-04 05:13:37
【问题描述】:
我在 txt 文件中有这种格式的过程数据。
testTag testTag2
10 18
6 15
7 15
9 19
请帮助我构建一个 SQLPlus 脚本,以便在每 5 秒后,这些值中的一个应按顺序更新 testTag 和 testTag2 的 IP_INPUT_VALUE 字段。
每隔 5 秒重新安排一次查询的选项,可以在需要时使用。
请帮忙。
【问题讨论】:
我在 txt 文件中有这种格式的过程数据。
testTag testTag2
10 18
6 15
7 15
9 19
请帮助我构建一个 SQLPlus 脚本,以便在每 5 秒后,这些值中的一个应按顺序更新 testTag 和 testTag2 的 IP_INPUT_VALUE 字段。
每隔 5 秒重新安排一次查询的选项,可以在需要时使用。
请帮忙。
【问题讨论】:
此问题经过多次尝试自行解决。我所要做的就是将 txt 格式更改为以下格式并运行查询
A B
NAME VALUE
----------------------------------------
testTag 10 6 7 9
testTag2 18 15 15 19
SQLPLus 查询:
local tagname char(24);
local value real;
local x,y integer;
y=2;
for x = y to 5 do
wait 00:00:05.00;
for (select line as ln from 'c:\data\Data.txt') do
tagname = substring(1 of ln between' ');
value = substring (x of ln between ' ');
UPDATE ip_analogdef SET IP_INPUT_VALUE = value,
QSTATUS(IP_INPUT_VALUE) = 'Good'
where name=tagname;
y=y+1;
end;
end;
【讨论】: