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

21 lines
601 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100))
BEGIN
/**
* Inserta nuevos registros en la tabla vn.expeditionState, por rutas
*
* @param vRouteFk Identificador de vn.route
* @param vStateCode Corresponde a vn.expeditionStateType.code
*/
INSERT INTO vn.expeditionState(expeditionFk, typeFk)
SELECT e.id, est.id
FROM vn.expedition e
JOIN vn.ticket t ON t.id = e.ticketFk
JOIN vn.expeditionStateType est ON est.code = vStateCode
WHERE t.routeFk = vRouteFk;
END$$
DELIMITER ;