Can't perform operation on inactive transaction when rollback

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
alex_kart
Posts: 2
Joined: Thu 29 Dec 2016 11:26

Can't perform operation on inactive transaction when rollback

Post by alex_kart » Thu 29 Dec 2016 11:39

I use TPgQuery with CachedUpdates=True and AutoCommit = False.
I want to send changes to database, run some additional checks and rollback transaction if checks fail

When I tried this code:

Code: Select all

   PgQuery1.ApplyUpdates;
    //Here will be some additional checks...
   connMain.Rollback; 
i had received an error "Can't perform operation on inactive transaction" on session rollback. I suspect that PgDac dataset makes commit after each statement in transaction, despite AutoCommit = off in dataset options

I use last trial version of PGDac

alex_kart
Posts: 2
Joined: Thu 29 Dec 2016 11:26

Re: Can't perform operation on inactive transaction when rollback

Post by alex_kart » Thu 29 Dec 2016 13:55

It looks like an old bug

azyk
Devart Team
Posts: 1078
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Can't perform operation on inactive transaction when rollback

Post by azyk » Fri 30 Dec 2016 09:36

The TPgQuery.AutoCommit property is not yet implemented in PgDAC. So, if transaction start wasn't initialized by user, PgDAC will automatically open and commit a transaction on calling TPgQuery.ApplyUpdates .

Therefore, to solve the described task, you should explicitly start a transaction before opening dataset:

Code: Select all

  PgQuery1.Connection.StartTransaction;
  PgQuery1.Open;

Post Reply