Page 1 of 1

Can't perform operation on inactive transaction when rollback

Posted: Thu 29 Dec 2016 11:39
by alex_kart
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

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

Posted: Thu 29 Dec 2016 13:55
by alex_kart
It looks like an old bug

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

Posted: Fri 30 Dec 2016 09:36
by azyk
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;