salix/db/routines/edi/procedures/ekt_loadNotBuy.sql

34 lines
627 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_loadNotBuy`()
BEGIN
/**
* Ejecuta ekt_load para aquellos ekt de hoy que no tienen vn.buy
*/
DECLARE vEktFk INTEGER;
DECLARE done BOOL;
DECLARE cursor1 CURSOR FOR
SELECT e.id
FROM edi.ekt e
LEFT JOIN vn.buy b ON b.ektFk = e.id
WHERE e.fec >= util.VN_CURDATE()
AND ISNULL(b.ektFk);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cursor1;
bucle: LOOP
FETCH cursor1 INTO vEktFk;
IF done THEN
LEAVE bucle;
END IF;
CALL edi.ekt_load(vEktFk);
END LOOP bucle;
CLOSE cursor1;
END$$
DELIMITER ;