Chapter 8. SQL Remote Design forAdaptive Ser verEnter prise
Managing conflicts
AnUPDATE conflict occurs when the following sequence of events takes
place:
1. User 1 updates a row at remote site 1.
2. User 2 updates the same row at remote site 2.
3. The update from User 1 is replicated to the consolidated database.
4. The update from User 2 is replicated to the consolidated database.
Whenthe SQL Remote Message Agent replicates UPDATE statements, it
doesso as a separate UPDATE for each row. Also, the message contains the
oldrow values for comparison. Whenthe update from user 2 arrives at the
consolidateddatabase, the values in the row are not those recorded in the
message.
UPDATE SalesRep
SET Dept=104
WHERE ID = 3
UPDATE SalesRep
SET Dept=103
WHERE ID = 3
First UPDATE
succeeds
Second UPDATE
overwrites the
first
ID Rep
Ann
2
1
Marc
Dept
101
101
3 Shih102>103
ID Rep
Ann
2
1
Marc
Dept
101
101
3 Shih 102>104
ID Rep
Ann
2
1
Marc
Dept
101
101
3 Shih 104
Defaultconflict resolution Bydefault, the UPDATE still proceeds, so that the User 2 update (the last to
reachthe consolidated database) becomes the value in the consolidated
database,and is replicated to all other databases subscribed to that row. In
general,the default method of conflict resolution is that the most recent
operation(in this case that from User 2) succeeds, and no report is made of
theconflict. Theupdate from User 1 is lost.
SQLRemote also allows custom conflict resolution, using a stored procedure
toresolve conflicts in a way that makes sense for the data being changed.
165