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

34 lines
768 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`routeInfo`(vRouteFk INT)
BEGIN
DECLARE vPackages INT;
DECLARE vM3 INT;
DECLARE vKg INT;
DECLARE vMatricula varchar(50);
SELECT sum(packages) as bultos
INTO vPackages
FROM vn.ticket t
WHERE routeFk = vRouteFk;
SELECT SUM(sv.physicalVolume), SUM(sv.physicalWeight)
INTO vM3, vKg
FROM vn.saleVolume sv
WHERE sv.routeFk = vRouteFk;
SELECT v.numberPlate as matricula
INTO vMatricula
FROM vn.route r
JOIN vn.vehicle v ON r.vehicleFk = v.id
WHERE r.id = vRouteFk;
SELECT vRouteFk as Ruta,
vPackages as Bultos,
vM3 as m3,
vKg as Kg,
vMatricula as Matricula;
END$$
DELIMITER ;