2024-08-02 08:28:50 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`(
|
|
|
|
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 ;
|