DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_getProblemsByTicket`(
    IN vTicketFk INT, 
    IN vIsTodayRelative TINYINT(1)
)
BEGIN
/**
 * Calcula los problemas de cada venta 
 * para un conjunto de tickets.
 *
 * @return Problems result
 */
    CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
        (INDEX (ticketFk))
        ENGINE = MEMORY
        SELECT vTicketFk ticketFk;

    CALL ticket_getProblems(vIsTodayRelative);

    SELECT * FROM tmp.saleProblems;

    DROP TEMPORARY TABLE
        tmp.ticket,
        tmp.ticketProblems;
END$$
DELIMITER ;
