0

I just want to know if i can call a procedure automatically when something happens. In particular, i would want to call a function that deletes records from a table when now() timestamp is one month past the timestamp atribute of the record. Something like

create or replace procedure eliminate_when_time_past()
  as $$
    begin
      if (now() is one month past the record timestamp) then
          delete from preñadas where hierro = ...
      end if;
    end;
  $$
language plpgsql

Is it possible?

  • Does this answer your question? [How to calculate DATE Difference in PostgreSQL?](https://stackoverflow.com/questions/24929735/how-to-calculate-date-difference-in-postgresql) – Ken White May 10 '20 at 01:29
  • You also don't need to use an IF at all. You can simply do this by using a WHERE clause in your DELETE SQL. – Ken White May 10 '20 at 01:31

0 Answers0