O'Reilly logo

Oracle Distributed Systems by Charles Dye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Oracle Detects and Resolves Conflicts

The package procedure table_name$RP is the package that detects conflicts as it applies DML at the destination site. Generating replication support for a table creates this package. As an example, generating replication support for the table DEPT produces the package DEPT$RP (shown in Example 15.1), which contains a procedure for each of the three types of DML: REP_DELETE, REP_INSERT, and REP_UPDATE. Each of these procedures passes exceptions on to the appropriate conflict resolution handler.

The boldfaced areas show how exceptions are passed to conflict handlers. As you can see, relatively few exceptions have a chance to be resolved: NO_DATA_FOUND for deletes (line 25) and updates (line 135) and DUP_VAL_ON_INDEX for inserts (line 68) and updates (line 155). Any other exceptions, such as VALUE_ERROR, result in entries in the DEFERROR data dictionary view.

Example 15-1. Detecting Conflicts with DEPT$RP

1 package body    "DEPT$RP" as
  2   procedure rep_delete(
  3     "DEPTNO1_o" IN NUMBER,
  4     "DNAME2_o" IN VARCHAR2,
  5     "LOC3_o" IN VARCHAR2,
  6     site_name IN VARCHAR2,
  7     propagation_flag IN CHAR) is
  8   begin
  9     if propagation_flag = 'N' then
 10       dbms_reputil.replication_off;
 11     end if;
 12     dbms_reputil.rep_begin;
 13     dbms_reputil.global_name := site_name;
 14     delete from "DEPT"	
 15     where ("DEPTNO1_o" = "DEPTNO"
 16     and  (("DNAME2_o" = "DNAME") or ("DNAME2_o" is NULL and "DNAME" is NULL))
 17     and  (("LOC3_o" = "LOC") or ("LOC3_o" is NULL and "LOC" is NULL)));
 18 if sql%rowcount ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required