2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`department_doCalc`()
|
2024-01-15 11:31:03 +00:00
|
|
|
proc: BEGIN
|
|
|
|
/**
|
|
|
|
* Recalculates the department tree.
|
|
|
|
*/
|
|
|
|
DECLARE vIsChanged BOOL;
|
|
|
|
|
|
|
|
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
|
|
|
DO RELEASE_LOCK('vn.department_doCalc');
|
|
|
|
RESIGNAL;
|
|
|
|
END;
|
|
|
|
|
|
|
|
IF !GET_LOCK('vn.department_doCalc', 0) THEN
|
|
|
|
LEAVE proc;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SELECT isChanged INTO vIsChanged
|
|
|
|
FROM department_recalc;
|
|
|
|
|
|
|
|
IF vIsChanged THEN
|
|
|
|
UPDATE department_recalc SET isChanged = FALSE;
|
|
|
|
CALL vn.department_calcTree;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
DO RELEASE_LOCK('vn.department_doCalc');
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|