INSERTROWEXISTS with the USEMAX Resolution

For this example, the USEMAX resolution is illustrated with the applicable before and after images for the record in the trail and in the database. It shows how to resolve an insert where the row exists in the source and target, but some or all row values are different.

Table 9-9 INSERTROWEXISTS Conflict with USEMAX Resolution

Image SQL Comments

Before image in trail

None (row was inserted on the source).

N/A

After image in trail

name='Mary'
phone='1234567890'
address='Oracle Pkwy'
salary=100
balance=100
comment=NULL
last_mod_time='9/1/10 3:00'

last_mod_time='9/1/10 3:00 is the after image of the resolution column. Since there is an after image, this will be used to determine the resolution.

Target database image

name='Mary'
phone='111111'
address='Ralston'
salary=200
balance=500
comment='aaa'
last_mod_time='9/1/10 1:00'

last_mod_time='9/1/10 1:00 is the current image of the resolution column in the target against which the resolution column value in the trail is compared.

Initial INSERT applied by Replicat that detects the conflict

SQL bind variables:

1)'Mary'
2)'1234567890'
3)'Oracle Pkwy'
4)100
5)100
6)NULL
7)'9/1/10 3:00'

This SQL returns a uniqueness conflict on 'Mary'.

UPDATE applied by Replicat to resolve the conflict

SQL bind variables:

1)'1234567890'
2)'Oracle Pkwy'
3)100
4)100
5)NULL
6)'9/1/10 3:00'
7)'Mary'
8)'9/1/10 3:00'

Because USEMAX is specified for INSERTROWEXISTS, Replicat converts the insert to an update, and it compares the value of last_mod_time in the trail record with the value in the database. The value in the record is greater, so the after images for columns in the trail file are applied to the target.