Question

I am trying to create one MySQL event which updates the table at every midnight. My query is like this:

CREATE EVENT postdetails_change_status 

ON SCHEDULE EVERY 1 DAY STARTS '2014-04-21 00:00:00'

DO BEGIN

    UPDATE postdetails SET status = 'completed' WHERE DeleteDate < CURDATE();

END;

This gives me error likeenter image description here

But when I run this update query normally, it works perfectly. Please help.

Reference: http://www.sitepoint.com/how-to-create-mysql-events/

Was it helpful?

Solution

Your script is correct but just change delimiter before script execution. try below:

delimiter |

CREATE EVENT postdetails_change_status 

ON SCHEDULE EVERY 1 DAY STARTS '2014-04-21 00:00:00'

DO BEGIN

    UPDATE postdetails SET status = 'completed' WHERE DeleteDate < CURDATE();

END |

delimiter ;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top