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

14 lines
381 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;