User's Manual
group or just for the user contained in the Message Agent connection string.
Using the CURRENT
REMOTE USER special
constant
The CURRENT REMOTE USER special constant holds the user ID of the
remote user sending the message. This can be used in RESOLVE UPDATE
triggers that place reports of conflicts into a table, to identify the user
producing a conflict.
Conflict resolution examples
This section describes some ways of using RESOLVE UPDATE triggers to
handle conflicts.
Resolving date conflicts
Suppose a table in a contact management system has a column holding the
most recent contact with each customer.
One representative talks with a customer on a Friday, but does not upload his
changes to the consolidated database until the next Monday. Meanwhile, a
second representative meets the customer on the Saturday, and updates the
changes that evening.
There is no conflict when the Saturday UPDATE is replicated to the
consolidated database, but when the Monday UPDATE arrives it finds the
row already changed.
By default, the Monday UPDATE would proceed, leaving the column with
the incorrect information that the most recent contact occurred on Friday.
Update conflicts on this column should be resolved by inserting the most
recent date in the row.
Implementing the
solution
The following RESOLVE UPDATE trigger chooses the most recent of the
two new values and enters it in the database.
CREATE TRIGGER contact_date RESOLVE UPDATE
ON contact
REFERENCING OLD AS old_name
NEW AS new_name
FOR EACH ROW
BEGIN
IF new_name.contact_date <
old_name.contact_date THEN
SET new_name.contact_date
= old_name.contact_date
END IF
END
If the value being updated is later than the value that would replace it, the
new value is reset to leave the entry unchanged.
124