22 lines
504 B
SQL
22 lines
504 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`duaParcialMake`(vDuaFk INT)
|
|
BEGIN
|
|
|
|
DECLARE vNewDuaFk INT;
|
|
|
|
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
|
|
AND value != customsValue;
|
|
|
|
END$$
|
|
DELIMITER ;
|