UPDATEROWEXISTS 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 update where the row exists in the source and target, but some or all row values are different.

Table 9-10 UPDATEROWEXISTS Conflict with USEMAX Resolution

Image SQL Comments

Before 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 before image of the resolution column.

After image in trail

phone='222222'
address='Holly'
last_mod_time='9/1/10 5:00'

last_mod_time='9/1/10 5: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='1234567890'
address='Oracle Pkwy'
salary=100
balance=600
comment='com'
last_mod_time='9/1/10 6:00'

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

Initial UPDATE applied by Replicat that detects the conflict

SQL bind variables:

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

This SQL returns a no-data-found error because the values for the balance, comment, and last_mod_time are different in the target.

All columns are used in the WHERE clause because the COMPARECOLS statement is set to ALL.

UPDATE applied by Replicat to resolve the conflict

SQL bind variables:

1)'Mary'
2)'222222'
3)'Holly'
4)100
5)100
6)NULL
7)'9/1/10 5:00'
8)'Mary'
9)'9/1/10 5:00'

Because the after value of last_mod_time in the trail record is less than the current value in the database, the database value is retained. Replicat applies the operation with a WHERE clause that contains the primary key plus a last_mod_time value set to less than 9/1/10 5:00. No rows match this criteria, so the statement fails with a "data not found" error, but Replicat ignores the error because a USEMAX resolution is expected to fail if the condition is not satisfied.