25 lines
643 B
MySQL
25 lines
643 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFreezeProblem`(
|
||
|
vClientFk INT
|
||
|
)
|
||
|
proc: BEGIN
|
||
|
/**
|
||
|
* Actualiza los problemas de los ticket de hoy y a fututo cuyo cliente
|
||
|
* se encuentra congelado o deja de estarlo
|
||
|
*
|
||
|
* @param vClientFk Id del cliente
|
||
|
*/
|
||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||
|
(INDEX(ticketFk))
|
||
|
ENGINE = MEMORY
|
||
|
SELECT t.id ticketFk, NOT c.isFreezed hasProblem
|
||
|
FROM ticket t
|
||
|
JOIN client c ON c.id = t.clientFk
|
||
|
WHERE t.shipped >= util.midnight()
|
||
|
AND c.id = vClientFk;
|
||
|
|
||
|
CALL ticket_setProblem('isFreezed');
|
||
|
|
||
|
DROP TEMPORARY TABLE tmp.ticket;
|
||
|
END$$
|
||
|
DELIMITER ;
|