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

22 lines
500 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaParcialMake`(vDuaFk INT)
BEGIN
DECLARE vNewDuaFk INT;
2024-01-25 16:33:54 +00:00
INSERT INTO dua(companyFk)
SELECT companyFk
FROM dua
WHERE id = vDuaFk;
SELECT LAST_INSERT_ID() INTO vNewDuaFk;
INSERT INTO duaEntry(duaFk, entryFk, value, customsValue)
SELECT vNewDuaFk, entryFk, value, value - customsValue
FROM duaEntry
WHERE duaFk = vDuaFk
2024-01-25 16:33:54 +00:00
AND value != customsValue;
END$$
DELIMITER ;