函数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
定时事件——调用函数

定时事件——调用函数

 

相关文章:

  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2021-11-04
  • 2021-11-20
  • 2022-01-10
  • 2022-02-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案