游标添加设备

上一篇 / 下一篇  2016-04-28 11:26:01 / 个人分类:工作--学习


create procedure pro_device()         创建存储过程
BEGIN
DECLARE t int default 0;               定义变量
DECLARE stop_flag int default 0;       
declare cur cursor FOR SELECT device_id 
FROM aiot_station.station_device WHERE station_id =419;
declare continue handler for sqlstate '02000' set stop_flag=1;
 open cur;
 fetch cur into t;
 while STOP_flag<>1 DO
INSERT into aiot_station.station_data(data_value,collect_time,device_id,create_time)
VALUES(ROUND((rand() * 10), 2),NOW(),t,NOW());
fetch  cur into t;
end while ;
 close cur;
 end 

call pro_device()

CREATE event insert_data
on schedule every 2 SECOND
on completion preserve 
do call pro_device();

alter event insert_data ON
completion PRESERVE enable;

TAG:

 

评分:0

我来说两句

日历

« 2024-05-11  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 4120
  • 日志数: 5
  • 建立时间: 2015-03-05
  • 更新时间: 2016-07-08

RSS订阅

Open Toolbar