Custom conflict resolution using triggers

Custom conflict resolution can take several forms. For example, in some applications, resolution can:

Custom conflict resolution requires you to write RESOLVE UPDATE triggers.

Using the RESOLVE UPDATE conflict resolution trigger

RESOLVE UPDATE triggers fire before each row is updated. The syntax for a RESOLVE UPDATE trigger is as follows:

CREATE TRIGGER trigger-name
RESOLVE UPDATE
OF column-name ON table-name 
[ REFERENCING [ OLD AS old-val ]
   [ NEW AS new-val ]
     [ REMOTE AS remote-val ] ] 
FOR EACH ROW 
BEGIN
   ... 
END

The REFERENCING clause allows access to the values in the row of the table to be updated (OLD), to the values the row is to be updated to (NEW) and to the rows that should be present according to the VERIFY clause (REMOTE). Only columns present in the VERIFY clause can be referenced in the REMOTE AS clause; other columns return a column not found error.

Using the CURRENT REMOTE USER special constant

CURRENT REMOTE USER is set by DBREMOTE when it executes the undocumented REMOTE USER statement. The value is NULL except for connections from DBREMOTE.

The CURRENT REMOTE USER can be used in RESOLVE UPDATE triggers that place reports of conflicts into a table, to identify the user producing a conflict.

See also

Resolving date conflicts
Resolving inventory conflicts