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

30 lines
589 B
MySQL
Raw Permalink Normal View History

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