salix/db/routines/vn/events/claim_changeState.sql

23 lines
530 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`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-07-09 10:46:50 +00:00
SELECT id INTO vClaimState
FROM claimState cs
2024-06-06 09:54:39 +00:00
WHERE cs.code = 'canceled';
UPDATE claim c
JOIN claimState cs ON cs.id = c.claimStateFk
2024-07-09 10:46:50 +00:00
SET c.claimStateFk = vClaimState
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');
END$$
DELIMITER ;