CREATE PROCEDURE P_DW_TAB_TEST()
BEGIN
REPLACE INTO dw.DW_TAB_TEST
SELECT A.*,ifnull(B.DW_TAB_TEST_TIME,NOW()) DW_TAB_TEST_TIME
FROM dw.TAB_TEST A
LEFT JOIN dw.DW_TAB_TEST B ON A.ID=B.ID
where A.LOG_TIME > NOW() - INTERVAL 1 MINUTE;
END;
CREATE EVENT IF NOT EXISTS E_DW_TAB_TEST
ON SCHEDULE EVERY 2 SECOND
STARTS '2022-06-17 17:06:41.000'
ON COMPLETION PRESERVE
DO CALL dw.P_DW_TAB_TEST() ;