salix/db/changes/10100-AllSaints/01-zone_getLanded.sql

39 lines
1.1 KiB
MySQL
Raw Normal View History

2019-10-29 11:29:38 +00:00
USE `vn`;
DROP procedure IF EXISTS `zone_getLanded`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT)
BEGIN
/**
* Devuelve una tabla temporal con el dia de recepcion para vShipped.
*
* @param vShipped Fecha de preparacion de mercancia
* @param vAddressFk Id de consignatario, %NULL para recogida
* @param vAgencyModeFk Id agencia
* @param vWarehouseFk vWarehouseFk
* @table tmp.zoneGetLanded Datos de recepción
2019-10-29 11:29:38 +00:00
*/
CALL zone_getFromGeo(address_getGeo(vAddressFk));
CALL zone_getOptionsForLanding(vShipped);
2019-10-29 11:29:38 +00:00
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
CREATE TEMPORARY TABLE tmp.zoneGetLanded
ENGINE = MEMORY
SELECT vWarehouseFk warehouseFk,
TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed,
2019-11-07 06:49:37 +00:00
vShipped shipped,
zo.zoneFk,
z.agencyModeFk
2019-10-29 11:29:38 +00:00
FROM tmp.zoneOption zo
JOIN zone z ON z.id = zo.zoneFk
WHERE agencyModeFk = vAgencyModeFk;
2019-10-29 11:29:38 +00:00
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
END$$
2019-11-07 06:49:37 +00:00
DELIMITER ;