33 lines
823 B
MySQL
33 lines
823 B
MySQL
|
USE `vn`;
|
||
|
DROP procedure IF EXISTS `ticketGetFullList`;
|
||
|
|
||
|
DELIMITER $$
|
||
|
USE `vn`$$
|
||
|
CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetFullList`()
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Obtiene un listado de tickets
|
||
|
* junto con el precio total y los problemas
|
||
|
*
|
||
|
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
|
||
|
* @return Listado de tickets
|
||
|
*/
|
||
|
CALL ticketGetTotal();
|
||
|
CALL ticketGetProblems();
|
||
|
|
||
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketFullList;
|
||
|
CREATE TEMPORARY TABLE tmp.ticketFullList ENGINE = MEMORY
|
||
|
SELECT t.*, tt.total, tp.problem
|
||
|
FROM tmp.ticket t
|
||
|
JOIN tmp.ticketTotal tt ON tt.ticketFk = t.ticketFk
|
||
|
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = t.ticketFk;
|
||
|
|
||
|
DROP TEMPORARY TABLE
|
||
|
tmp.ticket,
|
||
|
tmp.ticketTotal,
|
||
|
tmp.ticketProblems;
|
||
|
END$$
|
||
|
|
||
|
DELIMITER ;
|
||
|
|