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

37 lines
910 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT)
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE vTicketFk INT;
2024-06-19 09:30:50 +00:00
DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tTicket;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
CALL vn.productionControl(vWarehouserFk,0) ;
2024-06-19 09:30:50 +00:00
DROP TEMPORARY TABLE IF EXISTS tTicket;
CREATE TEMPORARY TABLE tTicket
SELECT ticketFk
FROM tmp.productionBuffer
JOIN alertLevel al ON al.code = 'FREE'
WHERE shipped = util.VN_CURDATE()
AND problem LIKE '%I:%'
AND (HH <= vHour OR HH = vHour AND mm < vMinute)
AND alertLevel = al.id;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO vTicketFk;
IF done THEN
LEAVE read_loop;
END IF;
CALL vn.ticket_DelayTruckSplit(vTicketFk);
END LOOP;
CLOSE cur1;
2024-06-19 09:30:50 +00:00
DROP TEMPORARY TABLE tTicket, tmp.productionBuffer;
END$$
DELIMITER ;