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

30 lines
678 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT)
BEGIN
/**
* Añade línea a itemShelvingSale y regulariza el carro
*
* @param vItemShelvingFk Id itemShelving
* @param vSaleFk Id de sale
* @param vQuantity cantidad a regularizar
*/
INSERT INTO itemShelvingSale(itemShelvingFk,
saleFk,
quantity,
userFk)
VALUES (vItemShelvingFk,
vSaleFk,
vQuantity,
getUser());
UPDATE itemShelving
SET visible = visible - vQuantity
WHERE id = vItemShelvingFk;
UPDATE vn.saleTracking
SET isChecked = 1
WHERE saleFk = vSaleFk;
END$$
DELIMITER ;