Merge pull request 'master' (!2811) from master into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2811 Reviewed-by: Jorge Penades <jorgep@verdnatura.es>
This commit is contained in:
commit
a61f68cbc9
|
@ -1,55 +1,55 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
||||||
vItemShelvingFk INT(10),
|
vItemShelvingFk INT(10),
|
||||||
vItemFk INT(10),
|
vItemFk INT(10),
|
||||||
vSectorFk INT
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
||||||
*
|
*
|
||||||
* @param vItemShelvingFk Id itemShelving
|
* @param vItemShelvingFk Id itemShelving
|
||||||
* @param vItemFk Id del artículo
|
* @param vItemFk Id del artículo
|
||||||
* @param vSectorFk Id del sector
|
* @param vSectorFk Id del sector
|
||||||
*/
|
*/
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET visible = 0,
|
SET visible = 0,
|
||||||
available = 0
|
available = 0
|
||||||
WHERE id = vItemShelvingFk
|
WHERE id = vItemShelvingFk
|
||||||
AND itemFk = vItemFk;
|
AND itemFk = vItemFk;
|
||||||
|
|
||||||
SELECT iss.id
|
SELECT iss.id
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
AND iss.itemFk = vItemFk
|
AND ish.itemFk = vItemFk
|
||||||
AND NOT iss.isPicked
|
AND NOT iss.isPicked
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk)
|
||||||
SELECT DISTINCT iss.saleFk
|
SELECT DISTINCT iss.saleFk, vSectorFk
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
AND ish.itemFk = vItemFk
|
AND ish.itemFk = vItemFk
|
||||||
AND NOT iss.isPicked;
|
AND NOT iss.isPicked;
|
||||||
|
|
||||||
DELETE iss
|
DELETE iss
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
AND ish.itemFk = vItemFk
|
AND ish.itemFk = vItemFk
|
||||||
AND NOT iss.isPicked;
|
AND NOT iss.isPicked;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
CALL itemShelvingSale_doReserve();
|
CALL itemShelvingSale_doReserve();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelvingSaleReserve DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK;
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK
|
||||||
|
FOREIGN KEY IF NOT EXISTS (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
Loading…
Reference in New Issue