I have a Postgresql table I'm using to store information about scheduled processes, including the last time a process was executed. Different processes have different requirements about how often they run.
I pull a list of processes I need to re-run like this:
SELECT * FROM processes WHERE last_run < now() - interval '2 hours'
I've added a new column called exec_interval
that has a value in minutes of how often the task should run so I can do away with the hard-coded value.
I'd like to do something like this:
SELECT * FROM processes WHERE last_run < now() - interval exec_interval || ' minutes'
But that throws a syntax error. Is there an accepted way to handle this scenario?