Update record five minutes after insertion

Asked

Viewed 47 times

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 that five minutes after the record was entered the bank would automatically change the value of flag_valido to 1. How could I do that? I researched some topics but found nothing that could solve my problem.

  • Search by EVENT

  • 2

    It would not be the case that, at the time you give the select in the record, compare the insertion date with the current date, and if greater than 5 min, returns as valid

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.