定时事件——调用函数

函数config() 内容
BEGIN
DECLARE t_error INT DEFAULT 0; -- 事务执行错误标志
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1;
    START TRANSACTION;
-- 断闸命令
insert into amp_command(dtuId,detectorNum,commandType,sendStatus,update_date,create_date,create_by) select left(machine_id,length(machine_id)-2),right(machine_id,2),1,0,NOW(),NOW(),create_by from amp_device_config where off_type = 1  and off_time <= now();
update amp_device_config set off_type = 0 where off_type = 1 and off_time <= now() ;
-- 合闸命令
insert into amp_command(dtuId,detectorNum,commandType,sendStatus,update_date,create_date,create_by) select left(machine_id,length(machine_id)-2),right(machine_id,2),2,0,NOW(),NOW(),create_by from amp_device_config where on_type = 1  and on_time <= now();
update amp_device_config set on_type = 0 where on_type = 1 and on_time <= now();

    -- SHOW ERRORS;
IF t_error = 1 THEN  
ROLLBACK;  
ELSE  
COMMIT;  
END IF;
select t_error;
END

 

转载于:https://www.cnblogs.com/wudage/p/9121973.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值