15.5 DBMS_RECTIFIER_DIFF: Comparing Replicated TablesIf you are not sure whether the data at two sites are identical, you can use the DBMS_RECTIFIER_DIFF package to find out. The DIFFERENCES procedure compares the data in a table at a master site with the same table at a reference site. After determining the differences, you can use DBMS_RECTIFIER_DIFF.RECTIFY to synchronize the tables. 15.5.1 Getting Started with DBMS_RECTIFIER_DIFFThe DBMS_RECTIFIER_DIFF package is created when the Oracle database is installed. The dbmsrepc.sql script (found in the built-in packages source directory, as described in Chapter 1) contains the source code for this package's specification. This script is called by catrep.sql , which must be run to install the advanced replication packages. The wrapped sql script prvtrctf.sql creates the public synonym DBMS_RECTIFIER_DIFF. No EXECUTE privileges are granted on DBMS_RECTIFIER_DIFF; only the owner (SYS) and those with the EXECUTE ANY PROCEDURE system privilege may execute the package. Table 15.6 summarizes the DBMS_RECTIFIER_DIFF programs.
15.5.2 DBMS_RECTIFIER_DIFF InterfaceThis section describes the programs available in the DBMS_RECTIFIER_DIFF package. 15.5.2.1 The DBMS_RECTIFIER.DIFFERENCES procedureThe DIFFERENCES procedure compares the data in a table at a master site with the same table at a reference site. The reference need not be the master definition site. The procedure stores discrepancies between the reference table and comparison table in a "missing rows" table, which the user must create. It populates the table specified by the missing_rows_oname1 parameter with rows that exist in the reference table but not the comparison table, and rows that exist in the comparison table but not the reference table. The table identified by the missing_rows_oname2 parameter has one record for every record in missing_rows_oname1, which identifies which site has the record. Here is the specification: PROCEDURE DBMS_RECTIFIER_DIFF.DIFFERENCES (sname1 IN VARCHAR2, oname1 IN VARCHAR2, reference_site IN VARCHAR2 := '', sname2 IN VARCHAR2, oname2 IN VARCHAR2, comparison_site IN VARCHAR2 := '', where_clause IN VARCHAR2 := '', {column_list IN VARCHAR2 := '' | array_columns IN dbms_utility.name_array,}, missing_rows_sname IN VARCHAR2, missing_rows_oname1 IN VARCHAR2, missing_rows_oname2 IN VARCHAR2, missing_rows_site IN VARCHAR2 := '', max_missing IN INTEGER, commit_rows IN INTEGER := 500); Parameters are summarized in the following table.
15.5.2.1.1 ExceptionsThe DIFFERENCES procedure may raise the following exceptions:
15.5.2.1.2 RestrictionsNote the following restrictions on calling the DIFFERENCES procedure:
15.5.2.1.3 ExampleFor an example of how to use the DIFFERENCES procedure, see the example under the RECTIFY procedure. 15.5.2.2 The DBMS_RECTIFIER_DIFF. RECTIFY procedureThe DIFFERENCES procedure paves the way for its companion procedure, RECTIFY, which synchronizes the reference table. Before running the RECTIFY procedure, always make sure that the updates to the comparison table will not violate any integrity, check, or NOT NULL constraints. Note that this procedure does not modify the reference table. Here's the specification: PROCEDURE DBMS_RECTIFIER_DIFF.RECTIFY (sname1 IN VARCHAR2, oname1 IN VARCHAR2, reference_site IN VARCHAR2 := '', sname2 IN VARCHAR2, oname2 IN VARCHAR2, comparison_site IN VARCHAR2 := '', {column_list IN VARCHAR2 := '' | array_columns IN dbms_utility.name_array}, missing_rows_sname IN VARCHAR2, missing_rows_oname1 IN VARCHAR2, missing_rows_oname2 IN VARCHAR2, missing_rows_site IN VARCHAR2 := '', commit_rows IN INTEGER := 500); Parameters are summarized in the following table.
15.5.2.2.1 ExceptionsThe RECTIFY procedure may raise the following exceptions:
15.5.2.2.2 RestrictionsNote the following restrictions on calling RECTIFY:
15.5.2.2.3 ExampleAssume that the table SPROCKET.DAILY_SALES is replicated between sites D7CA.BIGWHEEL.COM (the references site) and D7NY.BIGWHEEL.COM (the comparison site). The following table shows the description of the DAILY_SALES table.
The following steps executed at D7CA.BIGWHEEL.COM would populate the tables missing_rows_daily_sales and missing_location_daily_sales and rectify these differences. These steps should be executed under the designated replication administrator account. Note that storage parameters are left out of the example for the sake of brevity and clarity, but they should be included whenever you run the DBMS_RECTIFIER_DIFF.DIFFERENCES procedure. CREATE TABLE missing_rows_daily_sales ( sales_id NUMBER(9), distributor_id NUMBER(6), product_id NUMBER(9), units NUMBER(9,2) ); CREATE TABLE missing_location_daily_sales ( present VARCHAR2(128), absent VARCHAR2(128), r_id ROWID ); BEGIN DBMS_REPCAT.SUSPEND_MASTER_ACTIVITY('SPROCKET'); DBMS_RECTIFIER_DIFF.DIFFERENCES( - sname1 => 'SPROCKET', oname1 => 'DAILY_SALES', reference_site => 'D7CA.BIGWHEEL.COM', sname2 => 'SPROCKET', oname2 => 'SPROCKET', comparison_site => 'D7NY.BIGWHEEL.COM', where_clause => NULL, column_list => 'SALES_ID,DISTRIBUTOR_ID,PRODUCT_ ID,UNITS', missing_rows_sname => 'REPADMIN', missing_rows_oname1 => 'MISSING_ROWS_DAILY_SALES', missing_rows_oname2 => 'MISSING_LOCATIONS_DAILY_SALES , missing_rows_site => 'D7CA.BIGWHEEL.COM', max_missing => 500, comit_rows => 100); DBMS_RECTIFIER_DIFF.RECTIFY( - sname1 => 'SPROCKET', oname1 => 'DAILY_SALES', reference_site => 'D7CA.BIGWHEEL.COM', sname2 => 'SPROCKET', oname2 => 'SPROCKET', comparison_site => 'D7NY.BIGWHEEL.COM', ID,UNITS', missing_rows_sname => 'REPADMIN', missing_rows_oname1 => 'MISSING_ROWS_DAILY_SALES', missing_rows_oname2 => 'MISSING_LOCATIONS_DAILY_SALES - missing_rows_site => 'D7CA.BIGWHEEL.COM', comit_rows => 100); END;
Copyright (c) 2000 O'Reilly & Associates. All rights reserved. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|