2024-06-06 09:45:09 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`claim_changeState`
|
|
|
|
ON SCHEDULE EVERY 1 DAY
|
|
|
|
STARTS '2024-06-06 07:52:46.000'
|
|
|
|
ON COMPLETION PRESERVE
|
|
|
|
ENABLE
|
|
|
|
DO BEGIN
|
|
|
|
|
2024-07-09 10:46:50 +00:00
|
|
|
DECLARE vClaimState INT;
|
2024-06-06 09:45:09 +00:00
|
|
|
|
2024-07-09 10:46:50 +00:00
|
|
|
SELECT id INTO vClaimState
|
2024-06-06 09:45:09 +00:00
|
|
|
FROM claimState cs
|
2024-06-06 09:54:39 +00:00
|
|
|
WHERE cs.code = 'canceled';
|
2024-06-06 09:45:09 +00:00
|
|
|
|
|
|
|
UPDATE claim c
|
|
|
|
JOIN claimState cs ON cs.id = c.claimStateFk
|
2024-07-09 10:46:50 +00:00
|
|
|
SET c.claimStateFk = vClaimState
|
2024-06-06 09:45:09 +00:00
|
|
|
WHERE c.created < util.VN_CURDATE() - INTERVAL 2 MONTH
|
2024-06-06 09:54:39 +00:00
|
|
|
AND cs.code IN('incomplete','coming','waiting','out');
|
2024-06-06 09:45:09 +00:00
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|