0

We just upgraded our software from Delphi 2009 to Alexandria, and it broke in some places, always related to nested clientdatasets.

For instance, I just traced the error

Record not found or changed by another user

received from a delete attempt. The main dataset contains 3 child datasets - let's call them A, B, and C. Clientdatasets B & C are "pointing" at the same physical table on our SQL server.

In Data.Win.ADODB, TCustomADODataSet.PSExecute, I can see the generated delete statements come in with their respective parameters:

  1. Record(s) from table A get deleted, and in DataSnap.Provider, TSQLResolver.DoExecSQL I see that RowsAffected is <> 0
  2. Record(s) from table B get deleted, and in DataSnap.Provider, TSQLResolver.DoExecSQL I see that RowsAffected is <> 0
  3. Record(s) from table C get deleted ???, and in DataSnap.Provider, TSQLResolver.DoExecSQL I see that RowsAffected is 0 and the 'Record not found or changed by another user' exception is triggered.

I assume this happens because 3) Table C attempts to delete the same record that just deleted for table B - thus the record cannot be found and the exception occurs.

My question: Short of rewiring much of the data module containing all these tables, is there an easier/preferred way to say "It is OK if deletes on table C fail" so that the whole master table delete goes through?

3
  • 1
    The short answer is to be sure to uncheck the TDataSetProvider.ResolveToDataSet and write your own TDataSetProvider.BeforeUpdateRecord event hander code. This would be specific to your application though, and nobody could write that code without knowing your database requirements. For guidance read Cary Jensen's books "Delphi in depth: Clientdatasets" (1st or 2nd edition) Sep 24 at 18:29
  • @Freddie, thanks for that. Too bad that I now do not know how to give your credit for your answer, since you posted after i semi-answered my own question... I tried deleting my own answer, but that still doesn't allow me to do so .., maybe because it's a comment and not a formal answer? Either way. I'd be happy to fix this!
    – tua
    Sep 25 at 18:53
  • Don't worry. I noted that you had already answered the question, when I typed the comment. Sep 26 at 6:12

1 Answer 1

-1

Since nobody offered a suggestion, I bit the bullet and changed one of the competing clientdatasets from nested to standalone - now everything works, just like I already suspected. Too bad that I had to go that route, as it leaves me with a rather "asymmetrical" solution...

1
  • 1
    This doesn't answer the question you asked, does it? If not, it doesn't belong in this space.
    – Ken White
    Sep 24 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.