2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Add`(vPalletFk INT, vTruckFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE vTotal INT DEFAULT 0;
|
|
|
|
|
|
|
|
IF vPalletFk = 0 THEN -- Nuevo pallet
|
|
|
|
|
|
|
|
INSERT INTO vn.expeditionPallet(truckFk)
|
|
|
|
VALUES(vTruckFk);
|
|
|
|
|
|
|
|
SELECT LAST_INSERT_ID() INTO vPalletFk;
|
|
|
|
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SELECT COUNT(expeditionFk) INTO vTotal FROM vn.expeditionScan WHERE palletFk = vPalletFk;
|
|
|
|
|
|
|
|
IF vTotal <> 0 THEN
|
|
|
|
SELECT expeditionFk,
|
|
|
|
palletFk
|
|
|
|
FROM vn.expeditionScan
|
|
|
|
WHERE palletFk = vPalletFk;
|
|
|
|
ELSE
|
|
|
|
SELECT 0 expeditionFk,vPalletFk palletFk;
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|