I have a query as a transaction, using BEGIN
and COMMIT
. When I run this as a query it succeeds, however when I run it through pg_cron
I receive the following error:
FATAL: EndTransactionBlock: unexpected state BEGIN
BEGIN;TRUNCATE app_top50;INSERT INTO xxx...;COMMIT;
Googling the error returns very few results.
pg_cron
source code has a comment about it:So you don't need to add
BEGIN; ... COMMIT;
block. Just add queries and they will be executed as single transaction.