You can create a PL/SQL function to handle a particular conflict. The following command set 'nodata_update_avi' function to be executed when there s 'NO_DATA' conflict
raised by Dbvisit Replicate for update operation on scott.avi table.
SET_CONFLICT_HANDLERS FOR TABLE scott.avi FOR UPDATE ON NO_DATA TO PLSQL scott.dbvisit.nodata_update_avi
Perhaps what needs to be stressed: there is no way to just modify the values and pass them back to apply. If you are not satisfied with the return value options (discard, retry, newer, older), you have to apply the change yourself.
if (!strcmp(result, "4")) return DECISION_FORCE;
if (!strcmp(result, "3")) return DECISION_DONE;
if (!strcmp(result, "2")) return DECISION_RETRY;
if (!strcmp(result, "1")) return DECISION_OVERWRITE;
if (!strcmp(result, "0")) return DECISION_IGNORE;
The function must have prototype:
f(apply_old_data table%rowtype, has_found_apply_row boolean, primary_key_data table%rowtype, new_data table%rowtype) return number;
The return values are:
- 0: discard
- 1: overwrite
- 2: retry
- 3: the PL/SQL function resolved the conflict by itself and made all necessary changes.
The function must not issue a commit, as the transaction may be yet rolled back, if a rollback happened on source.
See also Data available to apply sessions for further information available to the handler.
The rec_* contain:
rec_old: the values at the target, queried by using key columns in the where clause. The boolean flag indicates whether any such record was found.
rec_key: old values at the source; mostly used to see the key, but it actually contains all supplementally logged values, too. Thus it will always (excl. LOBs, LONGs) include the modified column, too.
rec_new: new (modified) values at the source.