2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`isPalletHomogeneus`(vExpedition INT)
|
|
|
|
RETURNS tinyint(1)
|
|
|
|
NOT DETERMINISTIC
|
|
|
|
READS SQL DATA
|
|
|
|
BEGIN
|
|
|
|
DECLARE vScanId INT;
|
|
|
|
DECLARE vDistinctRoutesInThePallet INT;
|
|
|
|
|
|
|
|
SELECT scan_id INTO vScanId
|
|
|
|
FROM vn2008.scan_line
|
|
|
|
WHERE code = vExpedition
|
|
|
|
LIMIT 1;
|
|
|
|
|
|
|
|
SELECT COUNT(*) INTO vDistinctRoutesInThePallet
|
|
|
|
FROM (
|
|
|
|
SELECT DISTINCT t.Id_Ruta
|
|
|
|
FROM vn2008.scan_line sl
|
2024-02-05 08:02:31 +00:00
|
|
|
JOIN expeditions e ON e.id = sl.code
|
|
|
|
JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticketFk
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE sl.scan_id = vScanId
|
|
|
|
AND t.Id_Ruta
|
|
|
|
) t1;
|
|
|
|
|
|
|
|
RETURN vDistinctRoutesInThePallet = 1;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|