26 lines
666 B
MySQL
26 lines
666 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRequestProblem`(
|
||
|
vSelf INT
|
||
|
)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Actualiza los problemas cuando el ticket tiene una petición de compra pendiente o
|
||
|
* deja de tenerla
|
||
|
* @param vSelf Id del ticket de la petición de compra
|
||
|
*/
|
||
|
DECLARE vHasProblem BOOL;
|
||
|
|
||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||
|
(INDEX(ticketFk))
|
||
|
ENGINE = MEMORY
|
||
|
SELECT t.id ticketFk, COUNT(tr.id) hasProblem
|
||
|
FROM ticket t
|
||
|
LEFT JOIN ticketRequest tr ON tr.ticketFk = t.id
|
||
|
WHERE t.id = vSelf
|
||
|
AND isOK IS NULL;
|
||
|
|
||
|
CALL ticket_setProblem('hasTicketRequest');
|
||
|
|
||
|
DROP TEMPORARY TABLE tmp.ticket;
|
||
|
END$$
|
||
|
DELIMITER ;
|