Time schedule using pg_timetable

77 views Asked by At

I'm currently working with an e-commerse database assignment and I want to use pg_timetable to schedule a fuction like this.

CREATE OR REPLACE FUNCTION update_condition_after_delay()
RETURNS VOID AS $$
BEGIN
    UPDATE shopping.order_item
    SET condition = 'Pending Pickup'
    WHERE created_at <= NOW() - INTERVAL '1 minute'
    AND condition = 'Pending Confirmation';
END;
$$ LANGUAGE plpgsql;

And this command in postgresql:

SELECT timetable.add_job('execute-func', '@every 2 minutes', 'SELECT public.update_condition_after_delay()');

Yesterday, it works once when i scheduled it but today, when i start the pg_admin4 again, it does not work but I can't find out why.

I had try to research some documents on pg_timetable and test if my installation is successful.

0

There are 0 answers