Jump to content

FireDAC Transactions commited when onClose ?! BUG ?


RobertoN

Recommended Posts

Hello ppl !

I changed from FireDAC to DEVART MyDAC because this problem I didin't find solution...

Ex.: (TFDConnection X MySQL)

UniMainModule.FDConnection.Open;

UniMainModule.FDConnection.StartTransaction;

UniMainModule.FDConnection.ExecSQL('INSERT INTO test(mystr) VALUES (''xxxxxx'');');

UniMainModule.FDConnection.ExecSQL('INSERT INTO test(mystr) VALUES (''yyyyy'');');

UniMainModule.FDConnection.Close;   //I closed without do the commit, but at this moment commit occurs on database !??? 

//I think if FDConnection.inTransaction so onClose must be Rollback, but Commit happens !?

 

With TMyConnection all works fine...

Well, but what is the solution to FireDAC ? The commit occurs when shutdown too, but this is very wrong ....

 

Roberto

Link to comment
Share on other sites

2 hours ago, RobertoN said:

//I think if FDConnection.inTransaction so onClose must be Rollback, but Commit happens !?

Hello,

By default the FireDAC application works in auto-commit mode, where a transaction is automatically started by FireDAC when it is required, and is committed on the successful command execution or rolled back on a failure....

http://docwiki.embarcadero.com/RADStudio/Rio/en/Managing_Transactions_(FireDAC)

Link to comment
Share on other sites

With MyDac you can work in 2 ways.

If you put in the connection object Autocommit:=true it does the job by itself.

Even if you have Autocommit:=True , if you explicitly start a transaction , you have to commit it the same way.

If you start it and don't commit it it's anybody's guess what's happening, but by closing the query it will try to commit it anyway. 

Link to comment
Share on other sites

7 hours ago, adragan said:

If you start it and don't commit it it's anybody's guess what's happening, but by closing the query it will try to commit it anyway. 

Well, this is the problem. I want it not try do commit it anyway, if I do not commit, so when close I need it try rollback. Note that because this, when admin shutdown the server it try commit on all connections inTrasaction, but imagine one accounting aplication... it will try commit when must be rollback.

I resolved it using MyDAC, but if is possible one solution with FireDAC I would like to know. Very thanks all.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...