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

28 lines
643 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Add`(vPalletFk INT, vTruckFk INT)
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 ;