Replication of Deferred Updates on Primary Keys

Updates on tables that have a unique column index are not supported by traditional replication, and the Replication Server reports errors.

The replication of updates to tables that have a unique column index is not supported, and Replication Server reports errors. For example, table t has a unique index on column c, with values 1, 2, 3, 4 and 5. A single update statement is applied to the table:

update t set c = c+1

Using traditional replication, this statement results in:

update t set c = 2 where c = 1
update t set c = 3 where c = 2
update t set c = 4 where c = 3
update t set c = 5 where c = 4
update t set c = 6 where c = 5

The first update attempts to insert a value of c=2 into the table. However, this value already exists in the table. Replication Server displays error 2601—an attempt to insert a duplicate key.

Adaptive Server® Enterprise solves this problem with the SQL statement feature, which avoids a duplicate-key error by deferring the updates and executing them in reverse order. However, non-Sybase data servers do not provide this feature, and the Replication Server DSI will crash if you attempt to replicate updates to a non-Sybase table that has a unique column index. To work around this problem, broaden the unique index definition.