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

23 lines
495 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;