28 lines
649 B
SQL
28 lines
649 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;
|