From 967443b4278edb3ae0e99f23bd14421713a53e17 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 12:26:16 +0200 Subject: [PATCH 1/4] fix: refs #7834 expeditionScan_Put --- db/routines/vn/procedures/expeditionScan_Put.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 9744a7cd7..a5afc824f 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -1,11 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`( + vPalletFk INT, + vExpeditionFk INT +) BEGIN - - REPLACE vn.expeditionScan(expeditionFk, palletFk) + IF (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN + REPLACE expeditionScan(expeditionFk, palletFk) VALUES(vExpeditionFk, vPalletFk); - + SELECT LAST_INSERT_ID() INTO vPalletFk; - + END IF; END$$ DELIMITER ; -- 2.40.1 From e03a1914d94e1f0a9eea3bda1afbff38b5f79af8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 07:27:36 +0200 Subject: [PATCH 2/4] fix: refs #7834 Throw --- db/routines/vn/procedures/expeditionScan_Put.sql | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index a5afc824f..2a3e00df7 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -5,10 +5,16 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put` ) BEGIN IF (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN - REPLACE expeditionScan(expeditionFk, palletFk) - VALUES(vExpeditionFk, vPalletFk); - - SELECT LAST_INSERT_ID() INTO vPalletFk; + CALL util.throw('Expedition not exists'); END IF; + + IF (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN + CALL util.throw('Pallet not exists'); + END IF; + + REPLACE expeditionScan(expeditionFk, palletFk) + VALUES(vExpeditionFk, vPalletFk); + + SELECT LAST_INSERT_ID() INTO vPalletFk; END$$ DELIMITER ; -- 2.40.1 From 54e6c63b8b246090686ed17511a1ca7c7a138a6f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 07:29:32 +0200 Subject: [PATCH 3/4] fix: refs #7834 SELECT --- db/routines/vn/procedures/expeditionScan_Put.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 2a3e00df7..68e124e4b 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -14,7 +14,5 @@ BEGIN REPLACE expeditionScan(expeditionFk, palletFk) VALUES(vExpeditionFk, vPalletFk); - - SELECT LAST_INSERT_ID() INTO vPalletFk; END$$ DELIMITER ; -- 2.40.1 From d1bb77d6ed2222e149aa9442997693aa2a871eeb Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 12:51:55 +0200 Subject: [PATCH 4/4] fix: refs #7834 expeditionScan_Put --- db/routines/vn/procedures/expeditionScan_Put.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 68e124e4b..cbc76d317 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -4,11 +4,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put` vExpeditionFk INT ) BEGIN - IF (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN + IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN CALL util.throw('Expedition not exists'); END IF; - IF (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN + IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN CALL util.throw('Pallet not exists'); END IF; -- 2.40.1