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

33 lines
599 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(vDuaFk INT)
BEGIN
DECLARE done BOOL DEFAULT FALSE;
DECLARE vInvoiceInFk INT;
DECLARE rs CURSOR FOR
SELECT invoiceInFk
FROM entry e
JOIN duaEntry de ON de.entryFk = e.id
WHERE de.duaFk = vDuaFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN rs;
FETCH rs INTO vInvoiceInFk;
WHILE NOT done DO
CALL vn2008.recibidaIvaInsert(vInvoiceInFk);
CALL invoiceInDueDay_recalc(vInvoiceInFk);
FETCH rs INTO vInvoiceInFk;
END WHILE;
CLOSE rs;
END$$
DELIMITER ;