Created
October 21, 2016 00:49
-
-
Save bpdarlyn/1d994a004e9f7a83d8676be4201c4599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER // | |
create procedure darlyn(in _pay int) | |
begin | |
declare _per integer; | |
declare _cap decimal(12,4); | |
declare _fee decimal (12,4); | |
declare _pcb decimal (12,4); | |
declare _pb decimal (12,4); | |
declare cur1 cursor for | |
select period, capital, fee_period, principal_capital_balance, principal_balance | |
from fee_contract_period where payment_plan_id = _pay order by period and period > 1; | |
declare continue handler for not found set done = true; | |
open cur1; | |
read_loop: loop | |
fetch cur1 into _per, _cap, _fee, _pcb, _pb; | |
update fee_contract_periods | |
set principal_capital_balance = _pcb - capital, | |
principal_balance = _pb - fee_period | |
where payment_plan_id = _pay and period = _per + 1; | |
end loop; | |
close cur1; | |
end | |
// | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment