Question

I'm trying to add an event to create an entry in the 'dealsArchive' table and then delete the entry from the 'deals' table. It needs to execute at a specific time.

Here is what I'm trying to use:

DELIMITER $$ 
CREATE EVENT testEvent
ON SCHEDULE AT CURRENT_TIMESTAMP + 1 HOUR
DO BEGIN
INSERT INTO dealsArchive (did, start, end, tagline, description) SELECT (did, start, end, tagline, description) FROM deals WHERE did=5;
DELETE FROM deals WHERE did=5;
END$$
DELIMITER ;

When I try to run this, I get the following error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HOUR
DO BEGIN

I've tried changing little things about the query, but nothing seems to fix the error. Why am I getting this error?

Thanks in advance.

Was it helpful?

Solution

replace that

    ON SCHEDULE AT CURRENT_TIMESTAMP + 1 HOUR

by

   ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top