mysql计划程序未运行

k4ymrczo  于 2021-08-09  发布在  Java
关注(0)|答案(0)|浏览(198)

我已经创建了一个mysql调度程序,它将每年用新数据更新表。我将当前日期和时间更改为31/12/2020 11:59:00pm,以查看调度程序是否工作。不幸的是,表在通过1/1/2021 00:00:00之后没有更新。但是,当我尝试在不改变时间的情况下安排每一分钟时,调度程序工作得很好。我的sql不正确吗?

DELIMITER $$
CREATE EVENT duplicate_public_holiday
ON SCHEDULE EVERY '1' YEAR
STARTS '2021-01-01 00:00:00'
    DO
      BEGIN
        CREATE TEMPORARY TABLE tmp SELECT `CalHID`, `CalDDate`, `CalDName`, `CalDTitle`, `CalDYear`, `IsActive`, `IsDeleted`, `CreatedBy`, `CreatedDate`, `CreatedTime`, `ModifiedBy`,`ModifiedDate`, `ModifiedTime`, `DeletedBy`, `DeletedDate`, `DeletedTime`
        FROM tbcalendardetail WHERE CalDYear=(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR), "%Y")) AND IsActive=1 AND IsDeleted=0;

        UPDATE tmp SET CalDYear=(DATE_FORMAT(NOW(), "%Y"));
        UPDATE tmp SET CreatedDate=(DATE_FORMAT(NOW(), "%Y-%m-%d"));
        UPDATE tmp SET CreatedTime=(DATE_FORMAT(NOW(), "%h:%i:%s"));

        INSERT INTO tbcalendardetail (`CalHID`, `CalDDate`, `CalDName`, `CalDTitle`, `CalDYear`, `IsActive`, `IsDeleted`, `CreatedBy`, `CreatedDate`, `CreatedTime`, `ModifiedBy`, `ModifiedDate`, `ModifiedTime`, `DeletedBy`, `DeletedDate`, `DeletedTime`) 
        SELECT * FROM tmp;

        DROP TABLE tmp;
      END$$
DELIMITER;

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题