To force the conflict, the target table is going to be updated to a different value to than the source table.
1. On the target table on the target server (dbv02), run the following SQL to update the value
No Format |
---|
sqlplus oe/oe oe@ttorcl_trg |
No Format |
---|
SQL> update SALES set AMOUNT_RECEIVED = 60 where SALES_STATUS = 'OVERDUE' and PROD_ID = 101; commit; |
2. The The AMOUNT_RECEIVED column is now different on the target as what it is on the source for record in record PROD_ID = 101. On 101 on the target database it is 60 and now differs from the source database it is NULL.
3. Update the AMOUNT_RECEIVED for PROD_ID = 101 on the source database. On source server (dbv01) run the following SQL to update the value
No Format |
---|
sqlplus oe/oe oe@ttorcl_src |
No Format |
---|
SQL> update SALES set AMOUNT_RECEIVED = 120
where SALES_STATUS = 'OVERDUE'
and PROD_ID = 101;
commit; |
4. This will create a conflict because the update statement will be replicated to the target database. The target value was already changed and so a conflict was created.
5. On the replication console the conflict will be shown.
No Format |
---|
APPLY IS running. Currently at plog 724 and SCN 14858536 (12/29/2013 13:59:45) and 1 apply conflicts so far (last at 29/12/2013 14:01:18) and WAITING on manual resolve of apply conflict id 724010046998. |
6. The type of conflict is shown against the sales table. The conflict is "Command affected 0 rows".
No Format |
---|
OE.SALES: 80% Mine:5/5 Unrecov:0/0 Applied:4/4 Conflicts:1/1 Last:29/12/2013 13:59:38/RETRY:Command affected 0 row(s). |
...
No Format |
---|
dbvrep> list conflict Information for conflict 724010046998 (current conflict): Table: OE.SALES at transaction 001e.008.00000060 at SCN 148585373144514 SQL text (with replaced bind values): update OE."SALES" set AMOUNT_RECEIVED = 120 where (1=1) and AMOUNT_RECEIVED IS NULL and PROD_ID = 101 Error: Command affected 0 row(s). Handled as: PAUSE Conflict repeated 21 times. |
...
9. Decide which value should be kept on the target database. Do you want to keep the value of AMOUNT_RECEIVED = 60 or AMOUNT_RECEIVED = 120? In this case we are going to keep the value of AMOUNT_RECEIVED = 120 as this is the value on the source system.
10. Resolve the conflict. There are different options to resolve the conflict. They can be viewed here: Resolving Current Conflict. In this case the update is going to be forced on the target so that both source and target will be in sync. The conflict handler is OVERWRITE
No Format |
---|
dbvrep> resolve conflict 724010046998 as OVERWRITE |
...
Use command "help resolve conflict" to view information about this command
...
.
...
11. The conflict will be resolved. The OVERWRITE removes the "AMOUNT_RECEIVED IS NULL" from the where clause to enable the update to proceed. The command console will no longer show the conflict. Note the Conflicts counter for table OE.SALES shows 1
No Format |
---|
APPLY IS running. Currently at plog 724 and SCN 14884102 (12/29/2013 15:21:38).
...
OE.SALES: 100% Mine:5/5 Unrecov:0/0 Applied:5/5 Conflicts:1/1 Last:29/12/2013 15:19:04/OK |
11. Compare both tables on source and target and verify that they are the same
No Format |
---|
SQL> select * from sales;
PROD_ID CUST_ID QUANTITY_SOLD AMOUNT_SOLD AMOUNT_RECEIVED SALES_STAT
---------- ---------- ------------- ----------- --------------- ----------
101 201 233 1299 120 OVERDUE
102 301 30 1099 1099 PAID
103 401 30 120 120 PAID
104 401 40 160 OVERDUE |