DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemPlacementFromTicket`(vTicket INT)
BEGIN
/**
 * Llama a itemPlacementUpdateVisible 
 * de los articulos de la tabla temporal tmp.itemPlacement(itemFk)
 * @treturn tmp.itemPlacement
 * @param vTicket Id del Ticket
 */

    DROP TEMPORARY TABLE IF EXISTS tmp.itemPlacement;
    CREATE TEMPORARY TABLE tmp.itemPlacement
        (PRIMARY KEY (itemFk))
		ENGINE = MEMORY
		SELECT s.itemFk
			FROM ticket t
				JOIN sale s ON s.ticketFk = t.id
			WHERE t.id = vTicket;
            
	CALL itemPlacementUpdateVisible();
    
	DROP TEMPORARY TABLE tmp.itemPlacement;
END$$
DELIMITER ;
