36 lines
866 B
SQL
36 lines
866 B
SQL
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;
|
|
DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket;
|
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
|
|
|
CALL vn.productionControl(vWarehouserFk,0) ;
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
|
CREATE TEMPORARY TABLE tmp.ticket
|
|
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;
|
|
END$$
|
|
DELIMITER ;
|