-- Get the remote user value from #remote
SELECT @remote_user = current_remote_user
FROM #remote
-- Report the problem
INSERT INTO ConflictLog ( lost_name,
won_name, remote_user )
VALUES ( @lost_name, @won_name, @remote_user )
-- Disallow the update from the Message Agent
-- by resetting the row in the Customer table
UPDATE Customer
SET name = @won_name
WHERE cust_key = @cust_key
END
Notes Thereare several points of note here:
Theuser ID of the remote user is stored by the Message Agent in the
current_remote_usercolumn of the temporary table #remote.
TheUPDATE from the Message Agent is applied before the procedure
runs,so the procedure has to explicitly replace the values. Thisis
differentfrom the case in SQL Remote for Adaptive Server Anywhere,
whereconflict resolution is carried out by BEFORE triggers.
Testingthe example
Totest the example
1. Create the tables and the procedure in the consolidated database, and add
themas conflict resolution objects to the Customer table.
2. Insert and commit a change at the consolidated database. For example:
UPDATE Customer
SET name = ’Consolidated Sports’
WHERE cust_key=’cust1’
go
COMMIT
go
3. Insert and commit a different change to the same line at the remote
database. For example:
UPDATE Customer
SET name = ’Field Sports’
WHERE cust_key=’cust1’
go
COMMIT
go
172