Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I do not think you can use a dynamic value for the <code>timestamp</code> used in the create event syntax. Instead run your event everyday, and you can use the <code>datediff</code> function in the where clause of the update query in the event to check which data should be updated. You could also check the exact date like this: <code>where day(now()) = day(commit_date) and month(now()) = month(commit_date) and year(now()) = year(commit_date) + 1;</code>, but you wouldn't update in the case of leap eyar, so you should use something like this:</p> <pre><code>delimiter || CREATE EVENT myevent2 ON SCHEDULE EVERY 1 DAY STARTS now() DO UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(computer_interest/100)) where app_loan_type = 'Computer Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(miscellaneous_interest/100)) where app_loan_type = 'Miscellaneous Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(motor_vehicle_interest/100)) where app_loan_type = 'Motor Vehicle Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(mv_insurance_interest/100)) where app_loan_type = 'Motor Vehicle Insurance Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(mv_repair_interest/100)) where app_loan_type = 'Motor Vehicle Repair Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(salary_advance_interest/100)) where app_loan_type = 'Salary Advance Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_yearly_intrst = (app_ln_amnt *(tertiary_interest/100)) where app_loan_type = 'Tertiary Loan' and datediff(date(now()),commit_date) &gt;= 365; UPDATE lms.loan SET app_mnthly_intrest = (app_yearly_intrst/12), app_quarterly_intrest = (NEW.app_mnthly_intrest * 3), app_amnt_owed = (app_ln_amnt+ app_yearly_intrst) where datediff(date(now()),commit_date) &gt;= 365; END|| </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload