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 (
|
2024-02-05 12:52:28 +00:00
|
|
|
SELECT DISTINCT t.routeFk
|
2024-01-15 11:31:03 +00:00
|
|
|
FROM vn2008.scan_line sl
|
|
|
|
JOIN vn2008.expeditions e ON e.expeditions_id = sl.code
|
2024-02-05 12:52:28 +00:00
|
|
|
JOIN ticket t ON t.id = e.ticket_id
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE sl.scan_id = vScanId
|
2024-02-05 12:52:28 +00:00
|
|
|
AND t.routeFk
|
2024-01-15 11:31:03 +00:00
|
|
|
) t1;
|
|
|
|
|
|
|
|
RETURN vDistinctRoutesInThePallet = 1;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|