This commit is contained in:
parent
cb5c660e13
commit
4dcc8b02a5
|
@ -0,0 +1,30 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCorordinates`(
|
||||||
|
vTicketFk INT,
|
||||||
|
vLongitude INT,
|
||||||
|
vLatitude INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Actualiza las coordenadas de una direccion
|
||||||
|
*
|
||||||
|
* @param vTicketFk id del ticket
|
||||||
|
* @param vLongitude longitud de la direccion
|
||||||
|
* @param vLatitude latitud de la dirrecion
|
||||||
|
*/
|
||||||
|
DECLARE vAddressFK INT;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SELECT addressFK INTO vAddressFK
|
||||||
|
FROM ticket
|
||||||
|
WHERE id = vTicketFk
|
||||||
|
FOR UPDATE;
|
||||||
|
|
||||||
|
UPDATE address
|
||||||
|
SET longitude = vLongitude,
|
||||||
|
latitude = vLatitude
|
||||||
|
WHERE id = vAddressFK;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -4,16 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
|
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN
|
||||||
THEN
|
CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude);
|
||||||
UPDATE address
|
|
||||||
SET longitude = NEW.longitude,
|
|
||||||
latitude = NEW.latitude
|
|
||||||
WHERE id IN (
|
|
||||||
SELECT addressFK
|
|
||||||
FROM ticket
|
|
||||||
WHERE id = NEW.ticketFk
|
|
||||||
);
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -4,16 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
|
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN
|
||||||
THEN
|
CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude);
|
||||||
UPDATE address
|
|
||||||
SET longitude = NEW.longitude,
|
|
||||||
latitude = NEW.latitude
|
|
||||||
WHERE id IN (
|
|
||||||
SELECT addressFK
|
|
||||||
FROM ticket
|
|
||||||
WHERE id = NEW.ticketFk
|
|
||||||
);
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
|
|
Loading…
Reference in New Issue