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

23 lines
489 B
SQL

DELIMITER $$
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 ;