I am trying to create an event on my table to run every few minutes to see if 'next_run' is now() and if yes add 'frequency' to 'next_run', but I am receiving syntax exception every time i do.
below is the table structure...
LAST_RUN |FREQUENCY| NEXT_RUN
----------------------------------------------------
2016-09-15 06:02:06 | 1 DAY | 2016-09-15 06:02:06
" and the code i am using is this...
UPDATE TASKS_MASTER_COPY
@num:=CAST(FREQUENCY) AS UNSIGNED,
@p :=SUBSTR(FREQUENCY, CHAR_LENGTH(@num)+2)
LAST_RUN=NEXT_RUN,
NEXT_RUN=NEXT_RUN + CASE
WHEN @p='YEAR' THEN DATE_ADD(NEXT_RUN, INTERVAL @num YEAR)
WHEN @p='MONTH' THEN DATE_ADD(NEXT_RUN, INTERVAL @num MONTH)
WHEN @p='DAY' THEN DATE_ADD(NEXT_RUN, INTERVAL @num DAY)
WHEN @p='WEEK' THEN DATE_ADD(NEXT_RUN, INTERVAL @num WEEK)
END
WHERE TASK_MASTER_ID=100;
Can someone please help me with this? Thanks in advance.