0
DROP EVENT `game_insert`; CREATE DEFINER=`numberBetting_user`@`%` EVENT `game_insert` ON SCHEDULE EVERY 5 MINUTE STARTS '2021-08-18 17:25:29' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN UPDATE `game` set `status` =0 where `status`=1; INSERT INTO `game`(`startTime`, `endTime`,`status`,`betting`) VALUES (now(),NOW() + INTERVAL 5 minute,1,1); END

This event would insert a record every 5 minutes. It was working fine in local(xampp) but in the live server, it is not inserting data. Though event scheduler is on.

enter image description here

Everything looks fine but the event is not doing its job.

2 Answers2

1

Add DELIMITER like below

DELIMITER $$
DROP EVENT `game_insert`; 
CREATE DEFINER=`numberBetting_user`@`%` EVENT `game_insert` ON 
SCHEDULE EVERY 5 MINUTE STARTS '2021-08-18 17:25:29' ON COMPLETION NOT PRESERVE ENABLE DO 
BEGIN 
UPDATE `game` set `status` =0 where `status`=1;
 INSERT INTO `game`(`startTime`, `endTime`,`status`,`betting`) VALUES (now(),NOW() + INTERVAL 5 minute,1,1); 
END$$
DELIMITER ;

Only when you are in mysql workbench, you don't need thejm because they are added automatically

nbk
  • 45,398
  • 8
  • 30
  • 47
0

SOLVED the issue. The problem was with my insert query that I was missing a value for a not null column. After I added the value in the insert query the event works fine. Thank you