salix/db/routines/vn/procedures/ticketClon_OneYear.sql

23 lines
489 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketClon_OneYear`(vTicketFk INT)
BEGIN
DECLARE vShipped DATE;
DECLARE vMaxDated DATE;
SELECT shipped, TIMESTAMPADD(YEAR,1,shipped)
INTO vShipped, vMaxDated
FROM vn.ticket
WHERE id = vTicketFk;
WHILE vShipped <= vMaxDated DO
SET vShipped = TIMESTAMPADD(WEEK, 1, vShipped);
CALL vn.ticketClon(vTicketFk, vShipped);
END WHILE;
END$$
DELIMITER ;