Page 1 of 1

How to use TpgQuery.AutoCommit properly?

Posted: Thu 04 Feb 2016 08:46
by Wodzu
Hello,

first of all I wanted to report that help is missing information about the AutoCommit property. Could you explain a little how this property works because when I use this code:

Code: Select all

 
  PgQuery1.SQL.Text := 'INSERT INTO master (device_id, type) VALUES(:P_device_id, :P_type'); 
  PgQuery1.Connection.Connected := True;
  PgQuery1.AutoCommit := False;
  PgQuery1.Params[0].Value := 101;
  PgQuery1.Params[1].Value := 'some text';
  PgQuery1.ExecSQL;
The query still inserts one row into the table. I would expect that the row will not be inserted because AutoCommit is false.

Regards.

Re: How to use TpgQuery.AutoCommit properly?

Posted: Fri 05 Feb 2016 09:59
by azyk
The AutoCommit property is not yet implemented in PgDAC, therefore its description is absent in documentation. Currently, we are developing a TPgTransaction component. As soon as this component is implemented, the AutoCommit property will be implemented along with it. We are going to release them in one of the next PgDAC versions.

Re: How to use TpgQuery.AutoCommit properly?

Posted: Fri 05 Feb 2016 16:16
by Wodzu
Thank you for your answer. Maybe it would be better to explicitly state in documentation that this feature is not yet implemented because now it causes confusion.

I was gonna ask how to pass a transaction between queries but I guess currently it is not possible.
May I have a suggestion? When implementing transaction object, please allow to pass it to the method: TpgConnection.ExecSQL() as well. Because now ExecSQL causes automatic commit after execution and sometimes it is better to do (pseudocode):

Code: Select all

Transaction: TpgTransaction;
Connection: TpgConnection;

Transaction.Active := True;
Connection.ExecSQL(SomeQuery, Transaction);
Connection.ExecSQL(SomeQuery, Transaction);
Connection.ExecSQL(SomeQuery, Transaction);
Transaction.Commit;

Re: How to use TpgQuery.AutoCommit properly?

Posted: Thu 11 Feb 2016 09:00
by azyk
Thank you for your comments. We will try to take them into account when implementing transactions (including TPgTransaction) in PgDAC.

Re: How to use TpgQuery.AutoCommit properly?

Posted: Thu 11 Feb 2016 19:12
by Wodzu
Thank you for listening to your customers.