35 lines
687 B
SQL
35 lines
687 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`(
|
|
vClientFk INT
|
|
)
|
|
BEGIN
|
|
/**
|
|
* Updates future ticket risk for a client.
|
|
*
|
|
* @param vClientFk Id client
|
|
*/
|
|
DECLARE vDone INT DEFAULT FALSE;
|
|
DECLARE vTicketFk INT;
|
|
DECLARE vTickets CURSOR FOR
|
|
SELECT id
|
|
FROM ticket
|
|
WHERE clientFk = vClientFk
|
|
AND shipped >= util.VN_CURDATE()
|
|
AND refFk IS NULL;
|
|
|
|
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 ; |