Should I use ApplyUpdates (0) or ApplyUpdates (-1)?

In Delphi XE, the dbExpress tutorial in the online documentation uses ApplyUpdates (-1):

// Client data set has provider do update. ClientDataSet1.ApplyUpdates(-1); 

Some online sources, however, say that it will have advantages for using ApplyUpdates (0), and it would be a common mistake or bad practice to use -1. It's true? And when and why should I choose 0 greater than -1 as the value of MaxErrors ?

+7
delphi documentation delphi-xe c ++ builder dbexpress
source share
1 answer

-1 Allows you to report unlimited errors, so every update in Delta ClientDataSet will be checked.

0 Allows you to avoid errors at all, which means that the first time you try to upgrade, you donโ€™t waste time trying to upgrade.

-1 may be appropriate if you have a lot of unrelated changes to transfer to the database. For example, when pumping back changes from offline use in the portfolio model. In this type of scenario, updates may fail because the records, on average, were updated by other users, but with one failure of the update, little can be said about the chances of other update failures. Then it would probably be more convenient for each update to be checked and receive a report of those that failed, so they can be addressed by the user.

0 is probably better suited in situations where it is fairly predictable that if one update fails, all or many other updates in the delta will also fail. It would be โ€œreckless" for ClientDataSet to try other updates when their likelihood of failure is also high. I must admit that itโ€™s hard for me to come up with a scenario in which this will be so.

+9
source share

All Articles