1

Hello expert I am working in banking software vendor company and we are working in PostgreSQL database due to load of work in office time(pick hour) I want to execute some function in specified time(off hour) with trigger. So please if you have any idea please help me.

2
  • Solution smells a bit. But put an if statement in your trigger checking the current hour and if 11pm for example continue with it, else don,t. I think this is dangerous though, as for one record the trigger will fire and for others they won’t, thus some rows have data modified via trigger and some don,t. The result isn’t idempotent, unless you are curing all rows previously missed. If this is the case why not schedule a sql to fire once a day Commented Nov 20, 2017 at 11:03
  • trigger saves NEW.PK_COLUMN to a SCHEDULED table. then schedule a job that will on wanted time go through SCHEDULED table, processing ids and removing them from SCHEDULED table. of course it would work only in case of linear changes. Commented Nov 20, 2017 at 11:27

1 Answer 1

1

A trigger should always be something fast. You don't want to hold transactions open for a couple of hours, that would be a really bad idea.

The correct solution for such a problem would be a queue. There are some existing implementations like PGQ, but I don't know if the'll meet your requirements.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.