User's Manual

-- 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 There are several points of note here:
The user ID of the remote user is stored by the Message Agent in the
current_remote_user column of the temporary table #remote.
The UPDATE from the Message Agent is applied before the procedure
runs, so the procedure has to explicitly replace the values. This is
different from the case in SQL Remote for Adaptive Server Anywhere,
where conflict resolution is carried out by BEFORE triggers.
Testing the example
To test the example
1. Create the tables and the procedure in the consolidated database, and add
them as 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