I have a cached updates scenario in which an existing batch detail record that is currently part of a batch, must be moved to a new batch. The parent record for the new batch is inserted and the detail record is updated with the key value of the new batch. The insert and the update are applied as a single transaction. The result is an Oracle key violation error.
The reason is that in TOracleSession.ApplyUpdates, inserts are processed after updates. In the scenario described above, the batch detail record that points to the new batch header record is updated before the header record is inserted. I would like to do this in a single transaction but processing updates before inserts prohibits that.
I am concerned about second guessing AllRoundAutomations but it seems to me that, in a well normalized database, processing inserts before updates would result in fewer dependency problems because key values are rarely, if ever, changed.
I always hesistate to change source code because developers always have good reasons for what they do. In this case I changed the order of the ApplyUpdates code so that inserts are processed before updates. In my testing everything works quite well but I am concerned that there is something well thought out by AllroundAutomations that I may be missing. I would like to understand the logic of updates being performed before inserts before I decide to retain this modification. Would you please explain it?
Many thanks.
- Dan
The reason is that in TOracleSession.ApplyUpdates, inserts are processed after updates. In the scenario described above, the batch detail record that points to the new batch header record is updated before the header record is inserted. I would like to do this in a single transaction but processing updates before inserts prohibits that.
I am concerned about second guessing AllRoundAutomations but it seems to me that, in a well normalized database, processing inserts before updates would result in fewer dependency problems because key values are rarely, if ever, changed.
I always hesistate to change source code because developers always have good reasons for what they do. In this case I changed the order of the ApplyUpdates code so that inserts are processed before updates. In my testing everything works quite well but I am concerned that there is something well thought out by AllroundAutomations that I may be missing. I would like to understand the logic of updates being performed before inserts before I decide to retain this modification. Would you please explain it?
Many thanks.
- Dan