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

24 lines
536 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByAwb`(IN awbFk varchar(18))
BEGIN
/**
* inserta en tmp.buyRecalc las compras de un awb
*
* @param awbFk
*/
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
CREATE TEMPORARY TABLE tmp.buyRecalc
SELECT b.id
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
JOIN awb a ON a.id = t.awbFk
WHERE a.code = awbFk;
CALL buy_recalcPrices();
DROP TEMPORARY TABLE tmp.buyRecalc;
END$$
DELIMITER ;