salix/db/routines/vn2008/procedures/emailYesterdayPurchasesLaun...

28 lines
493 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`emailYesterdayPurchasesLauncher`()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE vMyClientId INT;
DECLARE rs CURSOR FOR
SELECT Id_Cliente
FROM Clientes
WHERE EYPBC != 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN rs;
FETCH rs INTO vMyClientId;
WHILE NOT done DO
CALL emailYesterdayPurchasesByConsigna(util.yesterday(), vMyClientId);
FETCH rs INTO vMyClientId;
END WHILE;
END$$
DELIMITER ;