2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`duaParcialMake`(vDuaFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE vNewDuaFk INT;
|
|
|
|
|
2024-01-25 16:33:54 +00:00
|
|
|
INSERT INTO dua(companyFk)
|
|
|
|
SELECT companyFk
|
2024-01-15 11:31:03 +00:00
|
|
|
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;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|