2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`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-08-28 09:59:46 +00:00
|
|
|
DECLARE vTicketIsTooLittle BOOL;
|
|
|
|
|
|
|
|
SELECT ticket_isTooLittle(vSelf) INTO vTicketIsTooLittle;
|
|
|
|
|
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-28 09:59:46 +00:00
|
|
|
WITH ticketData AS (
|
2024-08-27 15:12:41 +00:00
|
|
|
SELECT addressFk, DATE(shipped) dated
|
|
|
|
FROM vn.ticket
|
|
|
|
WHERE id = vSelf
|
|
|
|
)
|
2024-08-27 15:39:54 +00:00
|
|
|
SELECT t.id ticketFk,
|
2024-08-28 09:59:46 +00:00
|
|
|
vTicketIsTooLittle hasProblem,
|
2024-08-27 15:39:54 +00:00
|
|
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
2024-08-27 15:12:41 +00:00
|
|
|
FROM vn.ticket t
|
2024-08-28 09:59:46 +00:00
|
|
|
JOIN ticketData td ON td.addressFk = t.addressFk
|
|
|
|
WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated);
|
|
|
|
|
2024-04-16 15:01:14 +00:00
|
|
|
CALL ticket_setProblem('isTooLittle');
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|