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

21 lines
694 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_excludeFromGeo`(vZoneGeo INT)
BEGIN
/**
* Excluye zonas a partir un geoFk.
*
* @table tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, landed, shipped) The computed options
* @param vZoneGeo The zone geo
* @return tmp.zoneOption The computed options
*/
DELETE t
FROM tmp.zoneOption t
JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
JOIN zoneGeo zg1 ON zg1.id = eg.geoFk
JOIN zoneGeo zg2 ON zg2.id = vZoneGeo
WHERE zg2.`path` LIKE CONCAT(zg1.`path`, zg1.id,'/%')
OR zg2.id = zg1.id;
END$$
DELIMITER ;