salix/db/routines/vn/procedures/client_riskAll.sql

27 lines
530 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_riskAll`()
BEGIN
/**
* Update the risk for all clients with pending tickets
*
*/
DECLARE vDone BOOL;
DECLARE vClientFk INT;
DECLARE cClients CURSOR FOR
SELECT id
FROM client;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
OPEN cClients;
myLoop: LOOP
SET vDone = FALSE;
FETCH cClients INTO vClientFk;
IF vDone THEN LEAVE myLoop; END IF;
CALL client_risk(vClientFk);
END LOOP;
CLOSE cClients;
END$$
DELIMITER ;