在bat中执行sql,并配置windows计划任务,并隐藏命令窗口 (转)

时间:2014-05-22 05:18:38   收藏:0   阅读:307

1.创建一个sql文件,test.sql;

INSERT INTO TR_HK_RC_TEMPERATURE2 (HWINSTANCEID, KPIITEMID, BRANCHID, COLLECTTIME, KPINUMBERVALUE,  INSERTTIME)
select scadadeviceid  hwinstanceid, kpiitemid ,channelid * 64 + sensorid+1 branchid,SYSDATE, dbms_random.value(20,40),SYSDATE  from TR_R_SRACKMAPPING a,(select deviceid from dt_devices  where devicetoptypeid = 6) b where a.deviceid = b.deviceid and  kpiitemid = 42;
INSERT INTO TR_HK_RC_TEMPERATURE6 (HWINSTANCEID, KPIITEMID, BRANCHID, COLLECTTIME, KPINUMBERVALUE,  INSERTTIME)
select scadadeviceid  hwinstanceid, kpiitemid ,channelid * 64 + sensorid+1 branchid,SYSDATE, dbms_random.value(20,40),SYSDATE  from TR_R_SRACKMAPPING a,(select deviceid from dt_devices  where devicetoptypeid = 6) b where a.deviceid = b.deviceid and  kpiitemid = 46;
/
commit;
exit;

 

2.创建sql.bat文件,

sqlplus cmscrfid_sit/cmscrfid_sit@orcl @test.sql

 

3.创建vbs文件,用于隐藏窗口。

Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c sql.bat",vbhide

 

创建任务,每分钟一次:
schtasks /create /sc minute /mo 1 /tn "InertTempratureData" /tr c:/runbat.vbs

 

删除任务:

schtasks /delete /tn "InertTempratureData"

在bat中执行sql,并配置windows计划任务,并隐藏命令窗口 (转),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!