Create event on several schedules : Create « Event « SQL / MySQL






Create event on several schedules

      
mysql>
mysql> CREATE TABLE EVENTS_INVOKED
    ->       (EVENT_NAME      VARCHAR(20) NOT NULL,
    ->        EVENT_STARTED   TIMESTAMP NOT NULL);
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql>
mysql>
mysql> CREATE EVENT NEXT_SUNDAY
    ->    ON SCHEDULE AT
    ->       CASE DAYNAME(NOW())
    ->          WHEN 'Sunday'    THEN NOW() + INTERVAL 7 DAY
    ->          WHEN 'Monday'    THEN NOW() + INTERVAL 6 DAY
    ->          WHEN 'Tuesday'   THEN NOW() + INTERVAL 5 DAY
    ->          WHEN 'Wednesday' THEN NOW() + INTERVAL 4 DAY
    ->          WHEN 'Thursday'  THEN NOW() + INTERVAL 3 DAY
    ->          WHEN 'Friday'    THEN NOW() + INTERVAL 2 DAY
    ->          WHEN 'Saturday'  THEN NOW() + INTERVAL 1 DAY
    ->       END
    ->    DO INSERT INTO EVENTS_INVOKED
    ->          VALUES ('NEXT_SUNDAY',NOW())
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql> drop table EVENTS_INVOKED;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
  








Related examples in the same category

1.Create event at TIMESTAMP(CURDATE() + INTERVAL 1 DAY, '11:00:00')
2.Create event
3.Create an event: do insert
4.CREATE EVENT ON SCHEDULE AT NOW() + INTERVAL 3 DAY
5.Create event at NOW() + INTERVAL (8 - DAYOFWEEK(NOW())) DAY
6.Create event on start ... end
7.Create event on schedule
8.Event with comments
9.Show event creation