0

I'm new to using events an transactions. What i need is to combine these two sets of code resulting in moving old data to a history table. What is wrong with the code? Tried many different syntaxes but error is: "#1064 - 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 ''History' ON SCHEDULE AT TIMESTAMP '2016-10-22 16:00:00' DO START TRA' at line 1"

DELIMITER !!
CREATE EVENT 'History'
ON SCHEDULE AT TIMESTAMP '2016-10-22 16:00:00'
DO
START TRANSACTION;
set @N := (now());
INSERT INTO ss_log_history select * from ss_log where tid < date_sub(@N,INTERVAL 15 DAY);
DELETE FROM ss_log WHERE tid < date_sub(@N,INTERVAL 15 DAY);
COMMIT;
END !!
DELIMITER ;
  • I still do not get it. As you should know one can be starring at code for hours without finding the error. Therefor i polite ask for help! That duplicate has not same syntax – user3260939 Oct 22 '16 at 16:30

1 Answers1

0

Remove the single quote ' around event name. It should be

CREATE EVENT History

Refer Documentation for more information

Rahul
  • 76,197
  • 13
  • 71
  • 125
  • That gives next error. Like I said, have tried a lot – user3260939 Oct 22 '16 at 16:08
  • #1064 - 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 'set @N := (now()); INSERT INTO ss_log_history select * from ss_log where tid < ' at line 5 – user3260939 Oct 22 '16 at 16:10