DELIMITER $$ CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;