Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDConnection.InTransaction change automaticaly


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Jul 5, 2016 1:00 AM Last Post By: Olivier BATON
Olivier BATON

Posts: 6
Registered: 7/10/05
TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2016 5:31 AM
Hello,
I have passe my implementation code from XE7 to Berlin, and I have a problem with the TFDConnection.InTransaction property.
I use a TFDQuery with a TFDConnection.
I start a transaction with the TFDConnection.StartTransaction method, and TFDConnection.InTransaction = true (ok).
I do the TFDQuery.ExecSQL method, and the TFDTransaction.InTransaction = false (in XE7 it stay false until the commit or rollback).
I try to change the TFDConnection.TxOptions.AutoCommit to false, same problem.
Have you some idea. Thank you.
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2016 11:35 AM   in response to: Olivier BATON in response to: Olivier BATON
Denis Laronde wrote:

Hello,
I have passe my implementation code from XE7 to Berlin, and I have a
problem with the TFDConnection.InTransaction property. I use a
TFDQuery with a TFDConnection. I start a transaction with the
TFDConnection.StartTransaction method, and
TFDConnection.InTransaction = true (ok). I do the TFDQuery.ExecSQL
method, and the TFDTransaction.InTransaction = false (in XE7 it stay
false until the commit or rollback). I try to change the
TFDConnection.TxOptions.AutoCommit to false, same problem. Have you
some idea. Thank you.

I cannot reproduce. I've tried using informix. In my case I have had
also to drop a TFDTransaction to the form and assign it to
FDConnectention1.Transaction (otherwise FDQuery1.ExecSQL didn't
finished).

My test code is:

  FDConnection1.Connected:=true;
  Memo1.Lines.Add('Connected, Transaction:
'+BoolToStr(FDConnection1.InTransaction, true));
  FDConnection1.StartTransaction;
  Memo1.Lines.Add('StartTransaction, Transaction:
'+BoolToStr(FDConnection1.InTransaction, true));
  FDQuery1.ExecSQL;
  Memo1.Lines.Add('ExecSQL, Transaction:
'+BoolToStr(FDConnection1.InTransaction, true));
  FDConnection1.Rollback;
  Memo1.Lines.Add('Rollback, transaction:
'+BoolToStr(FDConnection1.InTransaction, true));


And the result is:

Connected, Transaction: False
StartTransaction, Transaction: True
ExecSQL, Transaction: True
Rollback, transaction: False
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 21, 2016 12:05 AM   in response to: Olivier BATON in response to: Olivier BATON
In general, FireDAC for some DB's is capable to detect that transaction
statevis changed after a SQL command execution. And that is reflected
in TFDConnection.InTransaction. To say more precisely, please provide:
1) Your FireDAC environment report:
http://docwiki.embarcadero.com/RADStudio/Berlin//en/DBMS_Environment_Reports_(FireDAC)
2) The SQL of your TFDQuery.

--
With best regards,
Dmitry
Olivier BATON

Posts: 6
Registered: 7/10/05
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 27, 2016 12:28 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Hello,

I'm sorry to not responde earlier.
The database is Oracle.
The problem append when the first request (after database connexion) is 'ALTER session SET NLS_COMP=LINGUISTIC'.

In my tests, if I do the requests
1. 'INSERT INTO my_table (id) VALUES (-99999)'
2. 'ALTER session SET NLS_COMP=LINGUISTIC'
The InTransaction property don't change after the 2nd request.

Edited by: Denis Laronde on Jun 27, 2016 12:31 AM
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 28, 2016 11:32 PM   in response to: Olivier BATON in response to: Olivier BATON
Thank you for reporting that. This is a bug in DX10.1 Berlin.
As a workaround move ALTER SESSION out of transaction.
I can provide a patch if required.

--
With best regards,
Dmitry
Olivier BATON

Posts: 6
Registered: 7/10/05
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2016 7:02 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Yes, if is possible.
Thank you
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2016 10:58 AM   in response to: Olivier BATON in response to: Olivier BATON
https://forums.embarcadero.com/thread.jspa?threadID=216054
I will appreciate if you will write feedback regarding the patch.

--
With best regards,
Dmitry
Olivier BATON

Posts: 6
Registered: 7/10/05
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2016 12:46 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Thank you, but how can I use your patch file ?
Olivier BATON

Posts: 6
Registered: 7/10/05
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 4, 2016 7:39 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
I have change the implementation in the "FireDAC.Phys.Oracle.pas" file like define in the patch.
But I have the same problem.

I need to compile something to take into account the modifications ?
Olivier BATON

Posts: 6
Registered: 7/10/05
Re: TFDConnection.InTransaction change automaticaly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 5, 2016 12:59 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Hello,

I have copy the updated file into my source project folder.
It work fine.
Thank you.

Edited by: Denis Laronde on Jul 5, 2016 12:59 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02