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

14 lines
377 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateBalance`(vSelf INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2))
BEGIN
/**
* Actualiza la columna balance de worker.
*
* @param selfFk, credit, debit
*/
UPDATE worker
SET balance = IFNULL(balance, 0) + IFNULL(vCredit, 0) - IFNULL(vDebit, 0)
WHERE id = vSelf;
END$$
DELIMITER ;