RobertoN Posted April 4, 2019 Share Posted April 4, 2019 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 4, 2019 Share Posted April 4, 2019 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) Quote Link to comment Share on other sites More sharing options...
adragan Posted April 4, 2019 Share Posted April 4, 2019 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. Quote Link to comment Share on other sites More sharing options...
RobertoN Posted April 4, 2019 Author Share Posted April 4, 2019 The problem is FireDAC with the config NOT in auto-commit mode, it is doing commit when close... I dont work with autocommit = true, it is always autommit = false. Quote Link to comment Share on other sites More sharing options...
RobertoN Posted April 4, 2019 Author Share Posted April 4, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.