2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-13 07:54:27 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittle`(
|
2024-04-16 15:01:14 +00:00
|
|
|
vSelf INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-05-02 16:13:12 +00:00
|
|
|
* Update the problems when the ticket is too small or is no longer so
|
2024-04-16 15:01:14 +00:00
|
|
|
*
|
|
|
|
* @param vSelf Id del ticket
|
|
|
|
*/
|
2024-06-27 11:01:42 +00:00
|
|
|
|
2024-04-16 15:01:14 +00:00
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-06-27 11:01:42 +00:00
|
|
|
(INDEX(ticketFk, isProblemCalcNeeded))
|
2024-04-16 15:01:14 +00:00
|
|
|
ENGINE = MEMORY
|
2024-08-27 15:12:41 +00:00
|
|
|
WITH tickets AS (
|
|
|
|
SELECT addressFk, DATE(shipped) dated
|
|
|
|
FROM vn.ticket
|
|
|
|
WHERE id = vSelf
|
|
|
|
)
|
2024-08-27 15:39:54 +00:00
|
|
|
SELECT t.id ticketFk,
|
|
|
|
ticket_isTooLittle(t.id) hasProblem,
|
|
|
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
2024-08-27 15:12:41 +00:00
|
|
|
FROM vn.ticket t
|
|
|
|
JOIN tickets ts ON ts.addressFk = t.addressFk
|
|
|
|
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated);
|
2024-04-16 15:01:14 +00:00
|
|
|
|
|
|
|
CALL ticket_setProblem('isTooLittle');
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|