Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdpii\tdpii_diverge004.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title>Tutorial: Converging Divergent Data</title> <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1 Build 005" /> <meta name="date" content="2009-06-04T17:1:3Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Tutorial: Converging Divergent Data" /> <meta name="relnum" content="11g Release 2 (11.2)" /> <meta name="partnum" content="E10703-01" /> <link rel="copyright" href="./dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> <link rel="stylesheet" href="./dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="tdpii_diverge003.htm" title="Previous" type="text/html" /> <script src="./callback.js" type="text/javascript"></script> <noscript>Your browser does not support JavaScript. This help page requires JavaScript to render correctly.</noscript> </head> <body> <div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr valign="bottom"> <td align="left"></td> <td align="center"><a href="tdpii_diverge003.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> </tr> </table> <p><a id="BABFHACE" name="BABFHACE"></a><a id="TDPII094" name="TDPII094"></a></p> <div class="sect1"><!-- infolevel="all" infotype="General" --> <h1>Tutorial: Converging Divergent Data<a id="sthref710" name="sthref710"></a><a id="sthref711" name="sthref711"></a><a id="sthref712" name="sthref712"></a></h1> <a name="BEGIN" id="BEGIN"></a> <p>This example continues the scenario described in <a href="tdpii_diverge003.htm#BABCDFGB">"Tutorial: Comparing Data in Two Different Databases"</a>. Complete the steps in that topic before continuing.</p> <p>When a shared database object has diverged at two different databases, you can use the <code>CONVERGE</code> procedure in the <code>DBMS_COMPARISON</code> package to converge the two instances of the database object. After the <code>CONVERGE</code> procedure runs successfully, the shared database object is consistent at the two databases. To run the <code>CONVERGE</code> procedure, you must specify the following information:</p> <ul> <li> <p>The name of an existing comparison created using the <code>CREATE_COMPARISON</code> procedure in the <code>DBMS_COMPARISON</code> package</p> </li> <li> <p>The scan ID of the comparison that you want to converge</p> </li> </ul> <p>The scan ID contains information about the differences that will be converged. In this example, the name of the comparison is <code>compare_departments</code> and the scan ID is <code>1</code>.</p> <p>Also, when you run the <code>CONVERGE</code> procedure, you must specify which database "wins" when the shared database object is converged. If you specify that the local database wins, then the data in the database object at the local database replaces the data in the database object at the remote database when the data is different. If you specify that the remote database wins, then the data in the database object at the remote database replaces the data in the database object at the local database when the data is different. In this example, the local database <code>ii1.example.com</code> wins.</p> <p class="orderedlisttitle">To converge divergent data in the hr.departments table at the ii1.example.com and ii2.example.com databases: </p> <ol> <li> <p>On a command line, open SQL*Plus and connect to the <code>ii1.example.com</code> database as the administrative user who owns the database link created in <a href="tdpii_diverge002.htm#BABDBGFC">"Tutorial: Preparing to Compare and Converge Data"</a>. For example, if the <code>SYSTEM</code> user owns the database link, then connect as the <code>SYSTEM</code> user:</p> <pre xml:space="preserve" class="oac_no_warn"> sqlplus system@ii1.example.com Enter password: <span class="italic">password</span> </pre> <p>See <a href="topicid:ADMQS0361">Starting SQL*Plus and Connecting to the Database</a> for more information about starting SQL*Plus.</p> </li> <li> <p>Run the <code>CONVERGE</code> procedure to converge the <code>hr.departments</code> table at the two databases:</p> <pre xml:space="preserve" class="oac_no_warn"> SET SERVEROUTPUT ON DECLARE scan_info DBMS_COMPARISON.COMPARISON_TYPE; BEGIN DBMS_COMPARISON.CONVERGE( comparison_name => 'compare_departments', scan_id => 1, scan_info => scan_info, converge_options => DBMS_COMPARISON.CMP_CONVERGE_LOCAL_WINS); DBMS_OUTPUT.PUT_LINE('Local Rows Merged: '||scan_info.loc_rows_merged); DBMS_OUTPUT.PUT_LINE('Remote Rows Merged: '||scan_info.rmt_rows_merged); DBMS_OUTPUT.PUT_LINE('Local Rows Deleted: '||scan_info.loc_rows_deleted); DBMS_OUTPUT.PUT_LINE('Remote Rows Deleted: '||scan_info.rmt_rows_deleted); END; / <span class="bold">Local Rows Merged: 0</span> <span class="bold">Remote Rows Merged: 2</span> <span class="bold">Local Rows Deleted: 0</span> <span class="bold">Remote Rows Deleted: 1</span> <span class="bold">PL/SQL procedure successfully completed.</span> </pre></li> </ol> <p>The <code>CONVERGE</code> procedure synchronizes the portion of the database object compared by the specified scan and returns information about the changes it made. Some scans might compare a subset of the database object. In this example, the specified scan compared the entire table. So, the entire table is synchronized, assuming no new differences appeared after the comparison scan completed.</p> <p>The local table wins in this example because the <code>converge_options</code> parameter is set to <code>DBMS_COMPARISON.CMP_CONVERGE_LOCAL_WINS</code> in the procedure. That is, for the rows that are different in the two databases, the rows at the local database replace the corresponding rows at the remote database. If some rows exist at the remote database but not at the local database, then the extra rows at the remote database are deleted. If instead you want the remote database to win, then set the <code>converge_options</code> parameter to <code>DBMS_COMPARISON.CMP_CONVERGE_REMOTE_WINS</code> in the procedure.</p> <p><a id="sthref714" name="sthref714"></a><a id="sthref715" name="sthref715"></a>In addition, if you run the <code>CONVERGE</code> procedure on a shared database object that is part of an Oracle Streams replication environment, then you might not want the changes made by the procedure to be replicated to other databases. In this case, you can set the following parameters in the <code>CONVERGE</code> procedure to values that will prevent the changes from being replicated:</p> <ul> <li> <p><code>local_converge_tag</code></p> </li> <li> <p><code>remote_converge_tag</code></p> </li> </ul> <p>When one of these parameters is set to a non-<code>NULL</code> value, a tag is set in the session that makes the changes during convergence. The <code>local_converge_tag</code> parameter sets the tag in the session at the local database, while the <code>remote_converge_tag</code> parameter sets the tag in the session at the remote database. If you do not want the changes made by the <code>CONVERGE</code> procedure to be replicated, then set these parameters to a value that will prevent Oracle Streams capture processes and synchronous captures from capturing the changes.</p> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdpii_repcont011.htm#BABICHGF">About Tags for Avoiding Change Cycling</a></p> <p><a href="tdpii_diverge001.htm#BABBAFCB">About Comparing and Converging Data in Different Databases</a></p> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=ARPLS868','newWindow').focus()"><span class="italic">Oracle Database PL/SQL Packages and Types Reference</span></a> for detailed information about the <code>DBMS_COMPARISON</code> package</p> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=STREP146','newWindow').focus()"><span class="italic">Oracle Streams Replication Administrator's Guide</span></a> for information about using the advanced features of the <code>DBMS_COMPARISON</code> package</p> </div> </div> <!-- class="sect1" --> <!-- Start Footer --> <div class="footer"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr> <td align="left"><span class="copyrightlogo">Copyright © 2007, 2009, Oracle and/or its affiliates. All rights reserved.</span><br /> <a href="./dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> <td align="center"><a href="tdpii_diverge003.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> </tr> </table> </div> <!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de