Conditionally setting MERGE-BY-FIELD on a data source
 
Forums / SmartComponent Library - Developer Forum / Conditionally setting MERGE-BY-FIELD on a data source

Conditionally setting MERGE-BY-FIELD on a data source

2 posts, 0 answered
  1. Simon Prinsloo
    Simon Prinsloo avatar
    11 posts
    Registered:
    20 Feb 2019
    12 Mar 2020
    Link to this post
     Hello

    We have a condition where two different automated processes sometimes tries to update the same record within milliseconds from each other a few times a day.

    Both read the same version of the record from the database via dataset models. Each process then proceeds to update the record, but not the same field.
    Either one will succeed and the other will get the "Record changed by another user" error.

    Setting the MERGE-BY-FIELD property for these two cases will solve the problem, but I cannot leave it on all the time because the table is updated very frequently and I am concerned about the performance impact it would have on the 99.9% of the other updates where this is not needed.

    I am therefore looking for ideas about the best place to set this property and especially an effective way of signalling that I am busy with these specific two transactions, without creating a messy structure.
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    13 Mar 2020 in reply to Simon Prinsloo
    Link to this post
    This is a very broad question.

    There are many places where you can set that property in the Data Access class.

    The final possibility is probably in the override to the SaveRowChanges method. Which conditions to use depend a lot on your use case.

    An alternative might also be to override SaveRowChances and handle the writing from the TT to the DD yourself, instead of relying on the SAVE-ROW-CHANGES method. 
2 posts, 0 answered