salix/db/routines/vn/procedures/travel_getEntriesMissingPac...

19 lines
459 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_getEntriesMissingPackage`(vSelf INT)
BEGIN
DECLARE vpackageOrPackingNull INT;
DECLARE vTravelFk INT;
SELECT travelfk INTO vTravelFk
FROM entry
WHERE id = vSelf;
SELECT e.id entryFk
FROM travel t
JOIN entry e ON e.travelFk = t.id
JOIN buy b ON b.entryFk = e.id
WHERE t.id = vTravelFk
AND (b.packing IS NULL OR b.packagingFk IS NULL);
END$$
DELIMITER ;