or missing_rows_oname is NULL or ` ' badnumber −23366 The max_missing is less than 1 or NULL dbms_repcat.commfailure −23302 Remote site is not accessible dbms_repcat.missingobject −23308 The tables oname1, oname2, missing_rows_oname1, or missing_rows_oname2 do not exist nosuchsite −23365 The reference_site, comparison_site, or missing_rows_site does not name a site 15.5.2.1.2 Restrictions Note the following restrictions on calling the DIFFERENCES procedure: • You must create tables missing_rows_sname.missing_rows_oname1 and missing_rows_sname.missing_rows_oname2 before running this procedure. • The columns in table missing_rows_oname1 must match the columns passed to column_list or array_columns exactly. • The replication group to which the tables belong must be quiesced. 15.5.2.1.3 Example For 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 procedure The 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. Name Description sname1 Name of schema that owns oname1. oname1 Table at reference_site (truth table). [Appendix A] What's on the Companion Disk? 15.5.2 DBMS_RECTIFIER_DIFF Interface 701 reference_site The global_name of site with truth table; if NULL or ` ' (default), truth table is assumed to be local. sname2 Name of schema that owns oname2. oname2 The comparison table. comparison_site The global_name of the site with comparison table. If NULL or ` ', table is assumed to be local. column_list A comma−separated list of one or more columns whose values are to be compared; if NULL or ` ' (default), then all columns are used. There should not be any white space after the commas. array_columns PL/SQL table of column names; either column_list or array_columns can be passed, not both. missing_rows_sname Name of schema that owns missing_rows_oname1. missing_rows_oname1 The name of the table containing records that do not exist in both truth table and comparison table. missing_rows_oname2 The table that holds information telling which table owns each record in missing_rows_oname1. missing_rows_site The global_name of the site where tables missing_rows_oname1 and missing_rows_oname2 exist; if NULL or ` ' (default), tables are assumed to be local. comming_rows Commit rows inserted into missing_row_oname1 after this many records. 15.5.2.2.1 Exceptions The RECTIFY procedure may raise the following exceptions: Name Number Description badname −23368 The sname, oname, missing_rows_sname, or missing_rows_oname is NULL or ` ' badnumber −23366 The max_missing is less than 1 or NULL dbms_repcat.commfailure −23302 Remote site is not accessible dbms_repcat.missingobject −23308 The tables oname1, oname2, missing_rows_oname1, or missing_rows_oname2 do not exist dbms_repcat.norepoption −2094 Replication option is not linked to kernel nosuchsite −23365 The reference_site, comparison_site, or missing_rows_site does not name a site 15.5.2.2.2 Restrictions Note the following restrictions on calling RECTIFY: • The DIFFERENCES procedure must have been run prior to running RECTIFY. • The replication group to which the tables belong should still be quiesced. • If duplicate rows exist in the reference table but not the comparison table they will be inserted into the comparison table. • [Appendix A] What's on the Companion Disk? 15.5.2 DBMS_RECTIFIER_DIFF Interface 702 If duplicate rows exist in the comparison table but not the reference table they will be deleted from the comparison table. 15.5.2.2.3 Example Assume 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. Column Name Data Type sales_id NUMBER(9) distributor_id NUMBER(6) product_id NUMBER(9) units NUMBER(9,2) 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', [Appendix A] What's on the Companion Disk? 15.5.2 DBMS_RECTIFIER_DIFF Interface 703 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; TIP: These procedures can take a long time to run. If the volume of data is significant, it will probably be easier for you to simply reinstantiate the comparison table by importing an export of the reference table. 15.4 DBMS_OFFLINE_OG: Performing Site Instantiation 15.6 DBMS_REPUTIL: Enabling and Disabling Replication Copyright (c) 2000 O'Reilly & Associates. All rights reserved. [Appendix A] What's on the Companion Disk? 15.5.2 DBMS_RECTIFIER_DIFF Interface 704 Chapter 15 Advanced Replication 15.6 DBMS_REPUTIL: Enabling and Disabling Replication Situations will arise when you need to perform DML on a replicated table without propagating the changes to other master sites. For example, if you have resolved a conflict and wish to update a row manually, you would not want to propagate your change. Or you might have a trigger on a replicated table that you want to fire only for updates that originate locally. The DBMS_REPUTIL package allows you to control whether updates propagate for the current session. 15.6.1 Getting Started with DBMS_REPUTIL The DBMS_REPUTIL package is created when the Oracle database is installed. The dbmsgen.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 script creates the public synonym DBMS_REPUTIL for the package and grants EXECUTE privilege on the package to public. All Oracle users can reference and make use of this package. Table 15.7 lists the programs available in this package. Table 15.7: DBMS_REPUTIL Programs Name Description Use in SQL? REPLICATION_OFF Turns replication off for the current session No REPLICATION_ON Turns replication on for the current session No 15.6.2 DBMS_REPUTIL Interface This section describes the programs available in the DBMS_REPUTIL package. 15.6.2.1 DBMS_REPUTIL.REPLICATION_OFF procedure The REPLICATION_OFF procedure works by setting a package variable off. The replication triggers can subsequently query this variable. This procedure is as simple as it can be: no parameters and no exceptions. PROCEDURE DBMS_REPUTIL.REPLICATION_OFF; 15.6.2.2 DBMS_REPUTIL.REPLICATION_ON procedure The REPLICATION_ON procedure reverses the effect of the REPLICATION_OFF procedure. It sets the package variable on. The specification follows: PROCEDURE DBMS_REPUTIL.REPLICATION_ON; 705 . with DBMS_REPUTIL The DBMS_REPUTIL package is created when the Oracle database is installed. The dbmsgen.sql script (found in the built−in packages source directory, as described in Chapter 1). synonym DBMS_REPUTIL for the package and grants EXECUTE privilege on the package to public. All Oracle users can reference and make use of this package. Table 15.7 lists the programs available