Home > Back-end >  Often not fully updated after used to commit the transaction
Often not fully updated after used to commit the transaction

Time:09-16

you much trouble, I use the Delphi, then
Adoconnection1. BeginTrans;
Adoconnection1. Execute (sql1);
Adoconnection1. Execute (sql2);
Adoconnection1. Execute (sql3);
Adoconnection1. Execute (sql4);
Adoconnection1. Execute (sql5);
Adoconnection1.Com mitTrans;

, and did not return after execution, application of roll, but many times, you will find, for example, in which a certain sql3 did not succeed, the modified data is not modified, and program at this time also not an exception is thrown, so there would be no rollback

Want to ask is what reason, how to solve, thank you
Hope can be solved, thank you again, if not enough, you can open again,

CodePudding user response:

After a Commit, the corresponding Dataset Query best want to Requery the refresh data
For example,
Adoconnection1. BeginTrans;
Adoconnection1. Execute (sql1);
Adoconnection1. Execute (sql2);
Adoconnection1. Execute (sql3);
Adoconnection1. Execute (sql4);
Adoconnection1. Execute (sql5);
Adoconnection1.Com mitTrans;
Adoquery1. Requery ();
Adoquery2. Requery ();
.

CodePudding user response:

1, this is the transaction processing, detailed check the SQL statement, whether there are any errors, as long as one is wrong, will not be able to perform any of the SQL,
2, there is only one you said, did not perform, unlikely, if appear this kind of problem, should be the MSSQL server software, this may be carried out entirely, sleep, and you missed again display (refresh) data to see,

CodePudding user response:

Update not success doesn't mean must be abnormal, the program itself is no problem, but your program logic may not be complete, not updating success requires certain processing is given

CodePudding user response:

Using SQL SERVER Profiler to track the execution of SQL statements

CodePudding user response:

Whether Sql3 have limited the where clause for execution

CodePudding user response:

reference 5 floor xiaocongzhi reply:
Sql3 have limited the where clause for compliance

In addition to this, another is carried out with SQL3, behind the two statements whether it overwrite the SQL3 is possible,

CodePudding user response:

Article 2 before you try to commit, behind three to do a transaction

CodePudding user response:

Use data set execution, set an attribute for the
AdoQuery. ExecuteOptions:=[TExecuteOption eoExecuteNoRecords];
AdoQuery. Execute (?) ;
AdoQuery. Execute (?) ;
AdoQuery. Execute (?) ;