我有以下代码
CREATE EVENT myevent2
ON SCHEDULE EVERY '1' YEAR
STARTS commit_date + INTERVAL 1 YEAR
DO
UPDATE lms.loan
if new.app_loan_type='Computer Loan' then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.computer_interest/100));
end if;
if new.app_loan_type="Miscellaneous Loan" then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.miscellaneous_interest/100));
end if;
if new.app_loan_type="Motor Vehicle Loan" then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.motor_vehicle_interest/100));
end if;
if new.app_loan_type="Motor Vehicle Insurance Loan" then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.mv_insurance_interest/100));
end if;
if new.app_loan_type="Motor Vehicle Repair Loan" then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.mv_repair_interest/100));
end if;
if new.app_loan_type="Salary Advance Loan" then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.salary_advance_interest/100));
end if;
if new.app_loan_type="Tertiary Loan" then
SET NEW.app_yearly_intrst = (NEW.app_ln_amnt *(NEW.tertiary_interest/100));
end if;
SET NEW.app_mnthly_intrest = (NEW.app_yearly_intrst/12);
SET NEW.app_quarterly_intrest = (NEW.app_mnthly_intrest * 3);
SET NEW.app_amnt_owed = (NEW.app_ln_amnt+ NEW.app_yearly_intrst);
END$$
我正在尝试创建一个事件来计算两种贷款类型的利息:“计算机贷款”和“杂项贷款”等,每年一次,但是每年一次取决于 commit_date 列,该列将是一年commit_date 列,然后如果 app_loan_type 是 'Computer Loan' 或 'miscellaneous Loan' 则计算年利息 我还计算月利息、季度利息和欠款总额,但我的主要问题是如何设置 commit_date 的间隔和当前日期为 1 年