salix/db/changes/10140-kings/00-clientRisk_update.sql

19 lines
366 B
SQL

DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2))
BEGIN
IF vAmount IS NOT NULL
THEN
INSERT INTO clientRisk
SET
clientFk = vClientId,
companyFk = vCompanyId,
amount = vAmount
ON DUPLICATE KEY UPDATE
amount = amount + VALUES(amount);
END IF;
END$$
DELIMITER ;