http://www.mysqltutorial.org/mysql-triggers/working-mysql-scheduled-event/
SHOW EVENTS \G
DELIMITER $$
DROP PROCEDURE UPDATE_TEMP_SUMMARY_VIEW01 $$
CREATE PROCEDURE UPDATE_TEMP_SUMMARY_VIEW01()
BEGIN
truncate table TEMP_SUMMARY_VIEW01;
insert ignore into TEMP_SUMMARY_VIEW01 select * from SOINVPOSUMMARY;
UPDATE FINISHED_JOB SET COUNT=COUNT+1 WHERE NAME='SO_SUMMARY';
END ;
$$
DELIMITER ;
DROP EVENT UPDATE_TEMP_SUMMARY_VIEW01;
DROP EVENT IF EXIST UPDATE_TEMP_SUMMARY_VIEW01;
CREATE EVENT UPDATE_TEMP_SUMMARY_VIEW01
ON SCHEDULE EVERY 60 SECOND
DO CALL UPDATE_TEMP_SUMMARY_VIEW01();
CALL UPDATE_TEMP_SUMMARY_VIEW01();
SET GLOBAL event_scheduler = ON;
SELECT * FROM FINISHED_JOB;
SHOW EVENTS FROM UPDATE_TEMP_SUMMARY_VIEW01;
沒有留言:
張貼留言