2024-08-02 08:28:50 +00:00
|
|
|
DELIMITER $$
|
2024-10-01 06:51:03 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`(
|
2024-08-02 08:28:50 +00:00
|
|
|
vClientFk INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-08-02 09:43:30 +00:00
|
|
|
* Updates future ticket risk for a client.
|
2024-08-02 08:28:50 +00:00
|
|
|
*
|
|
|
|
* @param vClientFk Id client
|
|
|
|
*/
|
|
|
|
DECLARE vDone INT DEFAULT FALSE;
|
|
|
|
DECLARE vTicketFk INT;
|
|
|
|
DECLARE vTickets CURSOR FOR
|
|
|
|
SELECT id
|
|
|
|
FROM ticket
|
|
|
|
WHERE clientFk = vClientFk
|
2024-08-02 09:43:30 +00:00
|
|
|
AND shipped >= util.VN_CURDATE()
|
|
|
|
AND refFk IS NULL;
|
2024-08-02 08:28:50 +00:00
|
|
|
|
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
|
|
|
|
|
|
|
OPEN vTickets;
|
|
|
|
l: LOOP
|
|
|
|
SET vDone = FALSE;
|
|
|
|
FETCH vTickets INTO vTicketFk;
|
|
|
|
|
|
|
|
IF vDone THEN
|
|
|
|
LEAVE l;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
CALL vn.ticket_setProblemRisk(vTicketFk);
|
|
|
|
END LOOP;
|
|
|
|
CLOSE vTickets;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|