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

31 lines
715 B
MySQL
Raw Normal View History

DELIMITER $$
2024-03-05 07:55:40 +00:00
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_mailSalesLauncher`()
BEGIN
/**
* Lanza el envío de correos electrónicos con el resumen de pedidos
* preparados para todos los clientes con el campo eypbc a TRUE.
*
* @param vSelf Id del cliente
* @param vDated Fecha de preparación
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vClientFk INT;
DECLARE vClients CURSOR FOR
SELECT id
FROM client
WHERE eypbc;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN vClients;
2024-03-05 07:55:40 +00:00
l: LOOP
SET vDone = FALSE;
FETCH vClients INTO vClientFk;
2024-03-05 07:55:40 +00:00
IF vDone THEN
LEAVE l;
END IF;
CALL client_mailSales(vClientFk, util.yesterday());
END LOOP;
END$$
DELIMITER ;