mysql - How can I update a column in a table after a time of its creation? -


i have table of commands , want change status of command 'expired' if status did not change else in 30 min

update : want happen every 30 min, must not anything. database update , change status of command 'expired' if command not handled in 30 min

don't that! instead, use view or computed column.

so, keep recent update date. should easy, because modifying table anyway.

then, can calculate expired as:

create view v_t      select t.*,            (case when status_update_dt < current_datetime - interval '30 minute'                  'expired'                  else status             end) new_status     t; 

of course, date/time functions depend on database (the above ansi syntax). and, databases support computed columns puts definition directly in table. convenient, because don't have change data; works when query data.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -