add new procedure in the DB
This commit is contained in:
parent
a290857dc1
commit
b78f83ae30
|
@ -0,0 +1,40 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `agencyHourGetFirstShipped`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve la primera fecha de envio disponible para una agencia en una direccion y un warehouse
|
||||
*
|
||||
* @param vAgencyMode id de la agencia en vn.agencyMode
|
||||
* @param vAddress id de la direccion
|
||||
* @param vWarehouse id del warehouse
|
||||
* @return vShipped la primera fecha disponible y vLanded la fecha de llegada/recojida
|
||||
*/
|
||||
DECLARE vAgency INT;
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vLanded DATE DEFAULT CURDATE();
|
||||
SELECT agencyFk INTO vAgency FROM agencyMode WHERE id= vAgencyMode;
|
||||
|
||||
l: LOOP
|
||||
|
||||
CALL agencyHourGetShipped(vLanded,vAddress,vAgency);
|
||||
SELECT shipped INTO vShipped
|
||||
FROM tmp.agencyHourGetShipped
|
||||
WHERE warehouseFk = vWarehouse LIMIT 1;
|
||||
|
||||
IF vShipped THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vLanded = DATE_ADD(vLanded, INTERVAL +1 DAY);
|
||||
|
||||
END LOOP;
|
||||
|
||||
SELECT vShipped,vLanded;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
Loading…
Reference in New Issue