Reputation: 11
I'm trying to update the data of a row every 30 minutes starting from the point where it was created. For example, if a row was inserted at 3:00 and another at 3:10, the first one would be updated at 3:30 and the second one at 3:40. I think I'd do this by saving the timestamp of creation + 30 minutes in a column, and when that timestamp is reached a trigger function will be triggered and the timestamp will be changed to 30 minutes after again. I have no idea how to make the trigger function though, how could I achieve this?
Upvotes: 1
Views: 580
Reputation: 248225
You cannot do that with a trigger functions, since triggers are only fired on data modifications.
You don't tell us why you are trying to do that, but I bet that you'd be happier with a different setup. Many UPDATE
s on a table make things difficult for PostgreSQL.
It would be better to leave the row the same and do whatever operation you have in mind in the query that selects the data from the table.
Upvotes: 1