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

30 lines
541 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_mergeSales`(vCollectionFk INT)
BEGIN
DECLARE vDone BOOL;
DECLARE vTicketFk INT;
DECLARE vTickets CURSOR FOR
SELECT ticketFk
FROM ticketCollection
WHERE collectionFk = vCollectionFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
OPEN vTickets;
l: LOOP
SET vDone = FALSE;
FETCH vTickets INTO vTicketFk;
IF vDone THEN
LEAVE l;
END IF;
CALL ticket_mergeSales(vTicketFk);
END LOOP;
CLOSE vTickets;
END$$
DELIMITER ;