Can't perform operation on inactive transaction when rollback

Can't perform operation on inactive transaction when rollback

Postby 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

Postby alex_kart » Thu 29 Dec 2016 13:55

It looks like an old bug
alex_kart
 
Posts: 2
Joined: Thu 29 Dec 2016 11:26

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

Postby 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;
azyk
Devart Team
 
Posts: 878
Joined: Fri 11 Apr 2014 11:47


Return to PostgreSQL Data Access Components