Update record five minutes after insertion

0

I have a table with the following structure:

tb_simulation:

id(INT) | codigo(VARCHAR) | flag_valido(INT) | data_hora(DATETIME) | valor(DEC)

I would like five minutes after the registry was entered the database automatically changed the value from flag_valido to 1. How could I do this? I researched some topics but found nothing that could solve my problem.

    
asked by anonymous 07.05.2017 / 19:30

1 answer

0

Activate event_schedule in your my.ini file and create an event to change status

CREATE EVENT evt_change_status ON SCHEDULE EVERY 1 MINUTE DO 
UPDATE nome_tabela
SET flag_valido = 1
WHERE flag_valido = 0 
AND data_hora <= NOW() - INTERVAL 5 MINUTE
    
16.11.2017 / 20:52