ヘッダーをスキップ
Oracle Streamsレプリケーション管理者ガイド
11g リリース1(11.1)
E05776-02
  目次
目次
索引
索引

戻る
戻る
 
次へ
次へ
 

A Oracle Streamsへのアドバンスト・レプリケーションの移行

アドバンスト・レプリケーションを使用して異なるサイト間でレプリケートされたデータベース・オブジェクトをメンテナンスしているデータベース管理者は、アドバンスト・レプリケーション環境をOracle Streams環境に移行できます。この付録では、このプロセスでの手順の概要を示し、各手順についてプロシージャと例を示して説明します。

この付録の内容は次のとおりです。


参照:

アドバンスト・レプリケーションの詳細は、『Oracle Databaseアドバンスト・レプリケーション』および『Oracle Databaseアドバンスト・レプリケーション・マネージメントAPIリファレンス』を参照してください。

移行プロセスの概要

ここでは、移行プロセスの概要を説明します。

移行スクリプトの生成と使用

DBMS_REPCAT.STREAMS_MIGRATIONプロシージャを使用すると、既存のアドバンスト・レプリケーション環境をOracle Streams環境に移行するSQL*Plusスクリプトを生成できます。マルチマスター・レプリケーション環境のマスター定義サイトでDBMS_REPCAT.STREAMS_MIGRATIONプロシージャを実行すると、指定した場所のファイルにSQL*Plusスクリプトが生成されます。スクリプトが生成された後、アドバンスト・レプリケーション環境の各マスター・サイトでそれを実行し、マスター・サイトごとにOracle Streams環境を設定します。レプリケーション・グループのOracle Streams環境を正常に生成するには、スクリプトの実行対象となるレプリケーション・グループに同じマスター・サイトが含まれている必要があります。レプリケーション・グループに異なるマスター・サイトが存在する場合、複数のスクリプトを生成して、各レプリケーション・グループをOracle Streamsに移行できます。

特定の管理タスクを実行するために、レプリケーション・グループのすべてのレプリケーション・アクティビティを停止または静止する必要がある場合があります。DBMS_REPCAT.STREAMS_MIGRATIONプロシージャを実行する場合は、レプリケーション・グループを静止する必要はありません。ただし、マスター・サイトで生成されたスクリプトを実行する場合は、Oracle Streamsに移行するレプリケーション・グループを静止する必要があります。レプリケーション・グループを静止してからマスター・サイトでスクリプトを実行するため、これらのサイトで既存の取得プロセス、伝播ジョブまたは適用プロセスを停止する必要はありません。

移行スクリプトの変更

生成された移行スクリプトでは、コメントを使用して、Oracle Streamsに変換できないアドバンスト・レプリケーション要素が示されます。また、これらの要素をOracle Streamsに変換するためのスクリプトの変更に関する推奨事項も示されます。この推奨事項に基づいて、実行前にスクリプトを編集することができます。必要に応じて、移行スクリプトをカスタマイズすることもできます。

このスクリプトは、PL/SQLプロシージャおよびファンクションを実行する際、すべてのパラメータを設定します。スクリプトを生成すると、パラメータにデフォルト値が設定されます。通常、これらのデフォルト値は変更する必要はありません。ただし、必要に応じてスクリプトを編集することで、これらのデフォルト・パラメータを変更することができます。デフォルトに設定されるパラメータは、次のとおりです。

  • include_dml

  • include_ddl

  • include_tagged_lcr

スクリプトの先頭には、スクリプト内のプロシージャとファンクションが使用する名前の変数のリストが含まれます。スクリプトを生成すると、これらの変数はデフォルト値に設定され、これらの値を変更する必要はありません。ただし、必要に応じてこれらの変数のデフォルト設定を変更することができます。変数では、キュー、取得プロセス、伝播および適用プロセスの名前が指定されます。

生成されたスクリプトによって実行されるアクション

移行スクリプトを実行すると、次のアクションが実行されます。

  • レプリケーション・グループにOracle Streamsに変換できない機能が含まれている場合、コメント内に警告が出力されます。

  • 必要に応じて、DBMS_STREAMS_ADM.SET_UP_QUEUEプロシージャを使用してANYDATAキューが作成されます。

  • 各表にDBMS_STREAMS_ADMIN.ADD_TABLE_PROPAGATION_RULESプロシージャを使用して、すべてのマスター・サイト間で伝播が構成されます。

  • 各表にDBMS_STREAMS_ADMIN.ADD_TABLE_RULESプロシージャを使用して、各マスター・サイトで取得が構成されます。

  • 各表にDBMS_STREAMS_ADMIN.ADD_TABLE_RULESプロシージャを使用して、他のすべてのマスター・サイトからの変更の適用が構成されます。

  • オブジェクトに対する変更が適用される各サイトで、各レプリケート・オブジェクトのインスタンス化SCNが設定されます。

  • ソース・データベースで必要なサプリメンタル・ログ・グループが作成されます。

  • キー列が設定されます(存在する場合)。

  • 移行するアドバンスト・レプリケーション環境に競合解消が構成されている場合は、競合解消が構成されます。

移行スクリプトのエラー

移行スクリプトの実行中にOracleにエラーが発生した場合、移行スクリプトは即時に終了します。このような状況が発生した場合、スクリプトを変更し、正常に実行されなかったすべてのコマンドを実行する必要があります。

更新可能なマテリアライズド・ビューの手動移行

移行スクリプトを使用して、更新可能なマテリアライズド・ビューを移行することはできません。アドバンスト・レプリケーション環境からOracle Streams環境への更新可能なマテリアライズド・ビューの移行は、手動で行う必要があります。

Oracle Streamsに移行できないアドバンスト・レプリケーション要素

Oracle Streamsでは、次の機能はサポートされていません。

  • BFILEROWIDデータ型、およびユーザー定義型(オブジェクト型、REF、VARRAY、ネストした表など)の列を持つ表に対する変更のレプリケーション

  • 同期レプリケーション

現行のアドバンスト・レプリケーション環境でこれらの機能を使用している場合、環境のこれらの要素はOracle Streamsに移行できません。この場合、現時点ではOracle Streamsへの環境の移行を中止するか、またはOracle Streamsに移行できるように環境を変更します。

移行スクリプトの生成の準備

移行スクリプトを生成する前に、次の条件がすべて満たされていることを確認してください。

移行スクリプトの生成と変更

移行スクリプトを生成するには、DBMS_REPCATパッケージのDBMS_REPCAT.STREAMS_MIGRATIONプロシージャを使用します。このプロシージャの構文は次のとおりです。

DBMS_REPCAT.STREAMS_MIGRATION (
     gnames              IN   DBMS_UTILITY.NAME_ARRAY,
     file_location       IN   VARCHAR2,
     filename            IN   VARCHAR2);

DBMS_REPCAT.STREAMS_MIGRATIONプロシージャには、次のパラメータがあります。

このプロシージャを実行すると、特定のレプリケーション・グループに対するOracle Streams環境を設定するスクリプトが生成されます。スクリプトをカスタマイズして、各マスター・サイトでそのスクリプトを実行することもできます。

Oracle Streamsに移行するアドバンスト・レプリケーション環境の例

図A-1に、この例でOracle Streamsに移行するアドバンスト・レプリケーション環境を示します。

図A-1 Oracle Streamsに移行するアドバンスト・レプリケーション環境

図A-1の説明が続きます。
図A-1「Oracle Streamsに移行するアドバンスト・レプリケーション環境」の説明

このアドバンスト・レプリケーション環境には、次の特性があります。

  • orc1.worldデータベースは、orc2.worldおよびorc3.worldを含む3方向のマスター構成のマスター定義サイトです。

  • orc1.worldデータベースは、mv1.worldマテリアライズド・ビュー・サイトのマスター・サイトです。

  • この環境は、3つのマスター・サイト間およびマスター・サイトとマテリアライズド・ビュー・サイトの間で、hrスキーマのデータベース・オブジェクトに対する変更をレプリケートします。レプリケーション・グループhr_repgは、レプリケート・オブジェクトを含んでいます。

  • マルチマスター環境のhr.countries表に、競合解消が構成されています。この表では、最新のタイムスタンプによる競合解消方法によって、競合が解消されます。

  • mv1.worldサイトのマテリアライズド・ビューは更新可能です。

このアドバンスト・レプリケーション環境を構成するには、『Oracle Databaseアドバンスト・レプリケーション・マネージメントAPIリファレンス』の次の各操作に関する項で説明されているタスクを実行してください。

  • 3つのマスター・サイトの設定

  • マテリアライズド・ビュー・サイトの設定(mv1.worldの設定のみ)

  • orc1.worldをマスター定義サイトとする3つのマスター・サイトのhr_repgマスター・グループの作成

  • hr.countries表に対するタイムスタンプによる競合解消の構成

  • orc1.worldhr_repgマスター・グループに基づく、mv1.worldのマテリアライズド・ビュー・グループの作成

このアドバンスト・レプリケーション環境の移行スクリプトを生成するには、次の手順を実行します。

  1. すべてのマスター・サイトでのOracle Streams管理者の作成

  2. ディレクトリへのアクセスの許可

  3. 移行スクリプトの生成

  4. 生成された移行スクリプトの作成の確認とスクリプトの変更


手順1: すべてのマスター・サイトでのOracle Streams管理者の作成

次の手順を実行して、Oracle Streamsに移行するレプリケーション・グループの各マスター・サイトにOracle Streams管理者を作成します。「Oracle Streamsに移行するアドバンスト・レプリケーション環境の例」に示した環境例の場合、orc1.worldorc2.worldおよびorc3.worldでこれらの手順を実行してください。

  1. ユーザーの作成、権限の付与および表領域の作成を行うことができる管理ユーザーとして接続します。

  2. Oracle Streams管理者用の表領域を作成するか、既存の表領域を使用します。たとえば、次の文では、Oracle Streams管理者用の新規表領域が作成されます。

    CREATE TABLESPACE streams_tbs DATAFILE '/usr/oracle/dbs/streams_tbs.dbf'
      SIZE 25 M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
    
  3. Oracle Streams管理者の役割を果たす新規ユーザーを作成するか、既存のユーザーを使用します。たとえば、新規ユーザーstrmadminを作成し、このユーザーがstreams_tbs表領域を使用するように指定するには、次の文を実行します。

    CREATE USER strmadmin IDENTIFIED BY password
       DEFAULT TABLESPACE streams_tbs
       QUOTA UNLIMITED ON streams_tbs;
    
    GRANT DBA TO strmadmin;
    

    注意:

    • この移行スクリプトでは、Oracle Streams管理者のユーザー名がstrmadminであると想定しています。Oracle Streams管理者がこれ以外のユーザー名を持つ場合は、移行スクリプトを編集して、すべてのインスタンスのstrmadminをOracle Streams管理者のユーザー名に置き換えてください。

    • Oracle Streams管理者にDBAロールが付与されていることを確認してください。


  4. 各マスター・サイトで、Oracle Streams管理者に必要な追加の権限を付与します。必要な権限は、個々のOracle Streams環境によって異なります。


    参照:

    Oracle Streams管理者に必要になる可能性がある追加権限の詳細は、『Oracle Streams概要および管理』を参照してください。

手順2: ディレクトリへのアクセスの許可

DBMS_REPCAT.STREAMS_MIGRATIONプロシージャのfile_locationパラメータで指定したディレクトリは、PL/SQLでアクセスできる必要があります。Oracle Streams管理者が現在アクセス可能なディレクトリ・オブジェクトがマスター定義サイトにない場合は、Oracle Streams管理者として接続し、SQL文CREATE DIRECTORYを使用してディレクトリ・オブジェクトを作成します。

ディレクトリ・オブジェクトは、ディレクトリの別名に類似しています。たとえば、コンピュータ・システムの/usr/scriptsディレクトリにディレクトリ・オブジェクトMIG2STR_DIRを作成するには、次のプロシージャを実行します。

CONNECT strmadmin@orc1.world
Enter password: password

CREATE DIRECTORY MIG2STR_DIR AS '/usr/scripts';

参照:

CREATE DIRECTORY文の詳細は、『Oracle Database SQL言語リファレンス』を参照してください。

手順3: 移行スクリプトの生成

移行スクリプトを生成するには、マスター定義サイトでDBMS_REPCAT.STREAMS_MIGRATIONプロシージャを実行し、適切なパラメータを指定します。たとえば、次のプロシージャを実行すると、レプリケーション・グループhr_repgを持つアドバンスト・レプリケーション環境を移行するスクリプトが生成されます。スクリプトはrep2streams.sqlという名前で、ローカル・コンピュータ・システムの/usr/scriptsディレクトリに生成されます。このディレクトリは、ディレクトリ・オブジェクトMIG2STR_DIRで表されます。

CONNECT strmadmin@orc1.world
Enter password: password

DECLARE
  rep_groups DBMS_UTILITY.NAME_ARRAY;
  BEGIN
    rep_groups(1) := 'HR_REPG';
    DBMS_REPCAT.STREAMS_MIGRATION(
      gnames         =>  rep_groups,
      file_location  =>  'MIG2STR_DIR',
      filename       =>  'rep2streams.sql');
END;
/

参照:

この例で生成されたスクリプトは、「Oracle Streams移行スクリプトに移行するアドバンスト・レプリケーションの例」を参照してください。

手順4: 生成された移行スクリプトの作成の確認とスクリプトの変更

移行スクリプトの生成後、指定したディレクトリを表示して、そのスクリプトが作成されたことを確認します。必要に応じて、次の機能をサポートするように変更することができます。

  • 加算、平均、優先グループまたはサイトの優先順位によるアドバンスト・レプリケーション競合解消方法を使用した競合解消が環境に必要な場合、ユーザー定義の競合解消方法を構成して競合を解消します。Oracle Streamsには、これらの方法と同等の競合解消方法が組み込まれていません。

    ただし、移行スクリプトでは、上書き、廃棄、最大および最小の競合解消方法が自動的にサポートされます。スクリプトは最古のタイムスタンプによる方法を最小の方法に、最新のタイムスタンプによる方法を最大の方法に自動変換します。タイムスタンプ競合解消方法を使用する場合、スクリプトでは、表のタイムスタンプ列を移入するために必要なトリガーがすでに存在するとみなされます。

  • 一意性競合の解消。

  • 削除の競合の解消。

  • 競合が発生した場合、複数の競合解消方法を指定した順序で実行します。Oracle Streamsでは、各列リストに指定できる競合解消方法は1つのみです。

  • キュー・ツー・キュー伝播。デフォルトでは、スクリプトではキュー・ツーdblink伝播が作成されます。

  • 手続き型レプリケーション。

  • 次のような、表以外のオブジェクトに対するデータ定義言語(DDL)変更のレプリケーション。

    • ファンクション

    • 索引

    • 索引タイプ

    • 演算子

    • パッケージ

    • パッケージ本体

    • プロシージャ

    • シノニム

    • トリガー

    • タイプ

    • タイプ本体

    • ビュー

これらのオブジェクトに対する変更は、アドバンスト・レプリケーションによってすべてのサイトでレプリケートされているため、移行スクリプトではこれらのオブジェクトを移行するためになんらかの操作を実行する必要はありません。Oracle Streams環境にDDLルールを追加することで、これらのオブジェクトの将来の変更と作成をサポートできます。

たとえば、orc1.worldデータベースの取得プロセスstreams_captureが、hrスキーマのすべてのデータベース・オブジェクトに対するDDL変更を取得するように指定するには、スクリプトに次の記述を追加します。

BEGIN
  DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
    schema_name        => 'hr',
    streams_type       => 'capture',
    streams_name       => 'streams_capture',
    queue_name         => 'strmadmin.streams_queue',
    include_dml        => FALSE,
    include_ddl        => TRUE,
    include_tagged_lcr => FALSE,
    source_database    => 'orc1.world');
END;
/

include_ddlパラメータがTRUEに設定されていることに注意してください。このパラメータをTRUEに設定することで、このプロシージャはhrスキーマに対するDDL変更のスキーマ・ルールを、取得プロセスのルール・セットに追加します。このルールは、取得プロセスに対し、hrスキーマおよびそのオブジェクトに対するDDL変更を取得するように指示します。DDL変更をレプリケートする場合、適切な伝播と適用プロセスに同様のルールを追加する必要があります。


参照:


Oracle Streamsへのアドバンスト・レプリケーションの移行の実行

ここでは、アドバンスト・レプリケーション環境からOracle Streams環境への移行を実行する方法について説明します。

この項の内容は、次のとおりです。

移行スクリプトの実行前の手順

移行スクリプトを実行する前に、次の手順を完了します。

  1. Oracle Streamsに関連する初期化パラメータの設定

  2. すべてのサイトでのアーカイブ・ロギングの有効化

  3. データベース・リンクの作成

  4. Oracle Streamsに移行する各レプリケーション・グループの静止


手順1: Oracle Streamsに関連する初期化パラメータの設定

各レプリケーション・データベースで、Oracle Streamsに関連する初期化パラメータを設定し、必要に応じてデータベースを再起動します。


参照:

Oracle Streamsに重要な初期化パラメータの詳細は、『Oracle Streams概要および管理』を参照してください。

手順2: すべてのサイトでのアーカイブ・ロギングの有効化

各マスター・サイトがARCHIVELOGモードで実行されていることを確認します。これは、取得プロセスを実行する際にARCHIVELOGモードである必要があるためです。前述の環境例では、orc1.worldorc2.worldおよびorc3.worldARCHIVELOGモードで実行されている必要があります。データベースのログ・モードを確認するには、V$DATABASE動的パフォーマンス・ビューのLOG_MODE列を問い合せます。


参照:

ARCHIVELOGモードでデータベースを実行する方法の詳細は、『Oracle Database管理者ガイド』を参照してください。

手順3: データベース・リンクの作成

各マスター・サイトで、Oracle Streams管理者から他のマスター・サイトのOracle Streams管理者へのデータベース・リンクを作成します。「Oracle Streamsに移行するアドバンスト・レプリケーション環境の例」に示した環境例の場合、次のデータベース・リンクを作成します。

CONNECT strmadmin@orc1.world
Enter password: password

CREATE DATABASE LINK orc2.world CONNECT TO strmadmin
   IDENTIFIED BY password USING 'orc2.world';

CREATE DATABASE LINK orc3.world CONNECT TO strmadmin
   IDENTIFIED BY password USING 'orc3.world';


CONNECT strmadmin@orc2.world
Enter password: password

CREATE DATABASE LINK orc1.world CONNECT TO strmadmin
   IDENTIFIED BY password USING 'orc1.world';

CREATE DATABASE LINK orc3.world CONNECT TO strmadmin
   IDENTIFIED BY password USING 'orc3.world';


CONNECT strmadmin@orc3.world
Enter password: password

CREATE DATABASE LINK orc1.world CONNECT TO strmadmin
   IDENTIFIED BY password USING 'orc1.world';

CREATE DATABASE LINK orc2.world CONNECT TO strmadmin
   IDENTIFIED BY password USING 'orc2.world';

手順4: Oracle Streamsに移行する各レプリケーション・グループの静止

Oracle Streamsに移行する各レプリケーション・グループのマスター定義サイトで、DBMS_REPCAT.SUSPEND_MASTER_ACTIVITYプロシージャを実行します。

前述の環境例では、orc1.worldがマスター定義サイトであり、hr_repgがOracle Streamsに移行するレプリケーション・グループです。したがって、レプリケーション管理者としてorc1.worldに接続し、SUSPEND_MASTER_ACTIVITYプロシージャを実行します。

CONNECT repadmin@orc1.world
Enter password: password

BEGIN
   DBMS_REPCAT.SUSPEND_MASTER_ACTIVITY (
      gname => 'hr_repg');
END;
/

マスター・グループが静止されるまで、次の手順に進まないでください。マスター・グループの状態を確認するには、DBA_REPGROUPデータ・ディクショナリ・ビューのSTATUS列を問い合せます。

移行スクリプトの実行

移行を行うには、次の手順を実行します。

  1. Oracle Streams管理者としての接続と各サイトでのスクリプトの実行

  2. すべてのサイトにおけるOracle Streams構成の正常終了の確認


手順1: Oracle Streams管理者としての接続と各サイトでのスクリプトの実行

前述の環境例では、SQL*Plusでorc1.worldorc2.worldおよびorc3.worldにOracle Streams管理者strmadminとして接続し、移行スクリプトrep2streams.sqlを実行します。

CONNECT strmadmin@orc1.world
Enter password: password

SET ECHO ON
SPOOL rep2streams.out
@rep2streams.sql

CONNECT strmadmin@orc2.world
Enter password: password

SET ECHO ON
SPOOL rep2streams.out
@rep2streams.sql

CONNECT strmadmin@orc3.world
Enter password: password

SET ECHO ON
SPOOL rep2streams.out
@rep2streams.sql

手順2: すべてのサイトにおけるOracle Streams構成の正常終了の確認

各サイトでスプール・ファイルをチェックして、エラーがないことを確認します。エラーがある場合は、正常に実行されなかった手順が実行されるようにスクリプトを変更し、スクリプトを再実行する必要があります。前述の環境例では、スプール・ファイルは各マスター・サイトのrep2streams.outです。

スクリプトの実行後の手順

移行プロセスを完了するには、次の手順を実行します。

  1. 各サイトでの移行済レプリケーション・グループの削除

  2. 各サイトでの取得プロセスの起動

  3. 各サイトでの取得プロセスの起動


手順1: 各サイトでの移行済レプリケーション・グループの削除

レプリケーション管理者としてマスター定義サイトに接続し、DBMS_REPCAT.DROP_MASTER_REPGROUPプロシージャを実行して、Oracle Streamsへの移行が正常に終了したレプリケーション・グループを削除します。


注意:

DROP_MASTER_REPGROUPプロシージャのdrop_contentsパラメータがFALSEに設定されていることを確認してください。TRUEに設定されている場合、レプリケートされたデータベース・オブジェクトが削除されます。

CONNECT repadmin@orc1.world
Enter password: password

BEGIN
   DBMS_REPCAT.DROP_MASTER_REPGROUP (
     gname         => 'hr_repg',
     drop_contents => FALSE,
     all_sites     => TRUE);
END;
/

各データベースで移行済のレプリケーション・グループが削除されていることを確認するには、DBA_REPGROUPデータ・ディクショナリ・ビューのGNAME列を問い合せます。移行済のレプリケーション・グループがどのデータベースの問合せでも出力されないことを確認する必要があります。

レプリケーション管理者が不要になった場合、このユーザーも削除できます。


注意:

Oracle Streamsの設定後は、アドバンスト・レプリケーションのアクティビティを再開しないでください。

手順2: 各サイトでの適用プロセスの起動

Oracle Streams管理者として接続中に次の問合せを実行すると、各サイトの適用プロセスの名前を表示できます。

SELECT APPLY_NAME FROM DBA_APPLY;

適用プロセス名がわかっている場合、Oracle Streams管理者として接続中にDBMS_APPLY_ADMパッケージのSTART_APPLYプロシージャを実行することで、各適用プロセスを起動できます。たとえば、次のプロシージャを実行すると、適用プロセスapply_from_orc2orc1.worldで起動されます。

CONNECT strmadmin@orc1.world
Enter password: password

BEGIN
  DBMS_APPLY_ADM.START_APPLY(
    apply_name => 'apply_from_orc2');
END;
/

新しいOracle Streams環境のすべてのデータベースで各適用プロセスを起動してください。

手順3: 各サイトでの取得プロセスの起動

Oracle Streams管理者として接続中に次の問合せを実行すると、各サイトの取得プロセスの名前を表示できます。

SELECT CAPTURE_NAME FROM DBA_CAPTURE;

取得プロセス名がわかっている場合、Oracle Streams管理者として接続中にDBMS_CAPTURE_ADMパッケージのSTART_CAPTUREプロシージャを実行することで、各取得プロセスを起動できます。たとえば、次のプロシージャを実行すると、取得プロセスstreams_captureorc1.worldで起動されます。

CONNECT strmadmin@orc1.world
Enter password: password

BEGIN
  DBMS_CAPTURE_ADM.START_CAPTURE(
    capture_name => 'streams_capture');
END;
/

新しいOracle Streams環境のすべてのデータベースで各取得プロセスを起動してください。

マテリアライズド・ビュー・グループを保持するマスター・サイトの再作成

1つ以上のマテリアライズド・ビュー・グループで、Oracle Streamsに移行したマスター・グループが使用されていた場合、マスター・グループを再作成して、そのマテリアライズド・ビュー・グループを保持する必要があります。したがって、マテリアライズド・ビュー・グループのマスター・サイトとして機能している各データベースは、そのマテリアライズド・ビュー・グループのマテリアライズド・ビューで使用されている表を含む単一マスター構成のレプリケーション・グループのマスター定義サイトとなる必要があります。

Oracle Streamsに移行された元のレプリケーション・グループと同様のレプリケーション・グループを作成するには、レプリケーション・マネージメントAPIを使用します。新しいレプリケーション・グループは、同じレプリケーション・グループ名、オブジェクト、競合解消方法およびキー列を持ちます。既存のマテリアライズド・ビュー・グループを保持するには、マテリアライズド・ビュー・グループのマスター・グループが含まれていた各マスター・サイトでそれぞれのマスター・グループを再作成し、マスター・グループでマスター・レプリケーション・オブジェクトを再作成して、マスター・グループのレプリケーション・サポートを再生成し、マスター・グループのレプリケーション・アクティビティを再開する必要があります。

たとえば、次のアドバンスト・レプリケーション環境を考えます。

rg1レプリケーション・グループがmdb1.netmdb2.netの両方でOracle Streamsに移行され、mv1.netのマテリアライズド・ビュー・グループmvg1およびmv2.netのマテリアライズド・ビュー・グループmvg2を保持する場合、Oracle Streamsへの移行後に、mdb1.netmdb2.netrg1レプリケーション・グループを再作成する必要があります。単一マスター環境で、mdb1.netmdb2.netの両方がrg1レプリケーション・グループのマスター定義サイトになるように構成します。

マテリアライズド・ビュー・サイトでマテリアライズド・ビュー・グループを削除または再作成する必要はありません。新しいマスター・レプリケーション・グループが元のレプリケーション・グループと同様であるかぎり、マテリアライズド・ビュー・グループに影響はありません。各マスター・オブジェクトのレプリケーション・サポートの生成が完了するまで、これらのマテリアライズド・ビュー・グループをリフレッシュしないでください(この項の手順3を参照)。また、各マスター・オブジェクトのレプリケーション・サポートの生成が完了するまで、更新可能なマテリアライズド・ビューを持つマテリアライズド・ビュー・サイトで遅延トランザクション・キューをプッシュしないでください。

「Oracle Streamsに移行するアドバンスト・レプリケーション環境の例」に示した環境例では、orc1.worldhr_repgレプリケーション・グループのみがmv1.worldのマテリアライズド・ビュー・グループのマスター・グループでした。mv1.worldのこのマテリアライズド・ビュー・グループを保持するには、レプリケーション管理者として接続中に次の手順を実行します。

  1. orc1.worldでマスター・グループhr_repgを作成します。

    CONNECT repadmin@orc1.world
    Enter password: password
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPGROUP (
          gname => 'hr_repg');
    END;
    /
    
  2. hr_repgマスター・グループにhrスキーマの表を追加します。これらの表は、mv1.worldのマテリアライズド・ビューのマスター表です。

    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'countries',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'departments',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'employees',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'jobs',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'job_history',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'locations',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
    BEGIN
       DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
          gname               => 'hr_repg',
          type                => 'TABLE',
          oname               => 'regions',
          sname               => 'hr',
          use_existing_object => TRUE,
          copy_rows           => FALSE);
    END;
    /
    
  3. hr_repgマスター・グループの各オブジェクトのレプリケーション・サポートを生成します。

    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'countries',
          type              => 'TABLE');
    END;
    /
    
    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'departments',
          type              => 'TABLE');
    END;
    /
    
    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'employees',
          type              => 'TABLE');
    END;
    /
    
    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'jobs',
          type              => 'TABLE');
    END;
    /
    
    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'job_history',
          type              => 'TABLE');
    END;
    /
    
    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'locations',
          type              => 'TABLE');
    END;
    /
    
    BEGIN
        DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
          sname             => 'hr',
          oname             => 'regions',
          type              => 'TABLE');
    END;
    /
    
  4. hr_repgマスター・グループのマスター・アクティビティを再開します。

    BEGIN
       DBMS_REPCAT.RESUME_MASTER_ACTIVITY (
          gname => 'hr_repg');
    END;
    /
    

    注意:

    hr_repgマスター・グループに追加した表ごとにマテリアライズド・ビュー・ログが存在します。ただし、レプリケーション・グループをOracle Streamsに移行した後にこれらのログを手動で削除した場合を除きます。マテリアライズド・ビュー・ログが存在しない場合は、これらのログを作成する必要があります。

Oracle Streams移行スクリプトに移行するアドバンスト・レプリケーションの例

環境に対して生成されたスクリプトの例を次に示します。

The following is an example script generated for the environment:
----------------------------------------------------------
-- Migration Script Generated on 12-JUN-05 by user STRMADMIN. --
----------------------------------------------------------

----------------------------------------------------------
--  ************** Notes and Assumptions ************** --
--
-- 1. The Oracle Streams Administrator is "strmadmin".
--    The user "strmadmin" must be created and granted the
--    required privileges before running the script.
--
-- 2. Names of queue tables, queues, capture processes
--    propagation jobs, and apply processes will be the
--    same at all sites. If the DBA wants different names,
--    he must edit the script manually before running it
--    at each master site.
--
-- 3. Archive logging must be enabled at all sites before
--    running the script.
--
-- 4. Users must set up database links for queue to queue
--    propagation, if needed.
--
-- 5. Repgroups must be quiesced before running the script.
----------------------------------------------------------

set pagesize 1000
set echo on
set serveroutput on
whenever sqlerror exit sql.sqlcode;

--
-- Raise error if Repgroups are not Quiesced.
--
declare
  repgroup_status VARCHAR2(10);
begin
  select status into repgroup_status
    from dba_repcat
   where gname = 'HR_REPG';

   if (repgroup_status != 'QUIESCED') THEN
     raise_application_error(-20000,
       'ORA-23310: object group "HR_REPG" is not quiesced.');
   end if;
exception when no_data_found then
  null;
end;
/

-------------------------------
-- Queue Owner
-------------------------------
-- streams queue owner at ORC1.WORLD
define QUEUE_OWNER_ORC1 = strmadmin

-- streams queue owner at ORC2.WORLD
define QUEUE_OWNER_ORC2 = strmadmin

-- streams queue owner at ORC3.WORLD
define QUEUE_OWNER_ORC3 = strmadmin

-------------------------------
-- Queue Table
-------------------------------
-- streams queue table at ORC1.WORLD
define QUEUE_TABLE_ORC1 = streams_queue_table

-- streams queue table at ORC2.WORLD
define QUEUE_TABLE_ORC2 = streams_queue_table

-- streams queue table at ORC3.WORLD
define QUEUE_TABLE_ORC3 = streams_queue_table

-------------------------------
-- Queue
-------------------------------
-- streams queue at ORC1.WORLD
define QUEUE_ORC1 = streams_queue

-- streams queue at ORC2.WORLD
define QUEUE_ORC2 = streams_queue

-- streams queue at ORC3.WORLD
define QUEUE_ORC3 = streams_queue

-------------------------------
-- Propagation names
-------------------------------
-- propagation process to ORC1.WORLD
define PROP_ORC1 = prop_to_ORC1

-- propagation process to ORC2.WORLD
define PROP_ORC2 = prop_to_ORC2

-- propagation process to ORC3.WORLD
define PROP_ORC3 = prop_to_ORC3

-------------------------------
-- Capture Process
-------------------------------
-- capture process to be used or created at the local site
define CAPTURE_NAME = streams_capture

-------------------------------
-- Apply processes
-------------------------------
-- apply process for applying LCRs from ORC1.WORLD
define APPLY_ORC1 = apply_from_ORC1

-- apply process for applying LCRs from ORC2.WORLD
define APPLY_ORC2 = apply_from_ORC2

-- apply process for applying LCRs from ORC3.WORLD
define APPLY_ORC3 = apply_from_ORC3

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- DEPT_LOCATION_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- EMP_MANAGER_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- INSERT_TIME of type TRIGGER belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_DEPARTMENT_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_EMPLOYEE_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- JHIST_JOB_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

--
-- ** WARNING ** --
-- Oracle Streams does not support the repobject
-- LOC_COUNTRY_IX of type INDEX belonging to repgroup HR_REPG.
-- The user can add DDL rules to the Oracle Streams environment
-- to support creation or any future modifications
-- of this type of object.
--

-------------------------------
-- Setup Queue
-------------------------------

variable local_db          varchar2(128);
variable local_queue_table varchar2(30);
variable local_queue       varchar2(30);
variable local_queue_owner varchar2(30);

-- get the local database name
declare
  global_name varchar2(128);
begin
  select global_name into :local_db from global_name;
  dbms_output.put_line('The local database name is: ' || :local_db);
end;
/

-- get the local queue table and queue name
begin
  if :local_db = 'ORC1.WORLD' then
    :local_queue_table := '&QUEUE_TABLE_ORC1';
    :local_queue := '&QUEUE_ORC1';
    :local_queue_owner := '&QUEUE_OWNER_ORC1';

  elsif :local_db = 'ORC2.WORLD' then
    :local_queue_table := '&QUEUE_TABLE_ORC2';
    :local_queue := '&QUEUE_ORC2';
    :local_queue_owner := '&QUEUE_OWNER_ORC2';

  elsif :local_db = 'ORC3.WORLD' then
    :local_queue_table := '&QUEUE_TABLE_ORC3';
    :local_queue := '&QUEUE_ORC3';
    :local_queue_owner := '&QUEUE_OWNER_ORC3';

  end if;

  dbms_output.put_line('The local queue owner is: ' || :local_queue_owner);
  dbms_output.put_line('The local queue table is: ' || :local_queue_table);
  dbms_output.put_line('The local queue name  is: ' || :local_queue);
end;
/

begin
  dbms_streams_adm.set_up_queue(
    queue_table => :local_queue_table,
    storage_clause => NULL,
    queue_name => :local_queue,
    queue_user => :local_queue_owner,
    comment => 'streams_comment');
end;
/

-------------------------------
-- Set Instantiation SCN
-------------------------------

variable flashback_scn number;

begin
  select dbms_flashback.get_system_change_number into :flashback_scn
    from dual;
  dbms_output.put_line('local flashback SCN is: ' || :flashback_scn);
end;
/

--
-- Setup instantiation SCN for ORC1.WORLD
--
begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."COUNTRIES" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."COUNTRIES"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."DEPARTMENTS" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."DEPARTMENTS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."EMPLOYEES" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."EMPLOYEES"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."JOBS" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."JOBS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."JOB_HISTORY" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."JOB_HISTORY"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."LOCATIONS" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."LOCATIONS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."REGIONS" at
  -- ORC1.WORLD
  --
  if (:local_db != 'ORC1.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC1.WORLD(
      source_object_name => '"HR"."REGIONS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

--
-- Setup instantiation SCN for ORC2.WORLD
--
begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."COUNTRIES" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."COUNTRIES"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."DEPARTMENTS" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."DEPARTMENTS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."EMPLOYEES" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."EMPLOYEES"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."JOBS" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."JOBS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."JOB_HISTORY" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."JOB_HISTORY"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."LOCATIONS" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."LOCATIONS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."REGIONS" at
  -- ORC2.WORLD
  --
  if (:local_db != 'ORC2.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC2.WORLD(
      source_object_name => '"HR"."REGIONS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

--
-- Setup instantiation SCN for ORC3.WORLD
--
begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."COUNTRIES" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."COUNTRIES"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."DEPARTMENTS" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."DEPARTMENTS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."EMPLOYEES" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."EMPLOYEES"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."JOBS" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."JOBS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."JOB_HISTORY" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."JOB_HISTORY"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."LOCATIONS" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."LOCATIONS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

begin
  --
  -- HR_REPG : Set instantiation SCN for "HR"."REGIONS" at
  -- ORC3.WORLD
  --
  if (:local_db != 'ORC3.WORLD') then
    dbms_apply_adm.set_table_instantiation_scn@ORC3.WORLD(
      source_object_name => '"HR"."REGIONS"',
      source_database_name => :local_db,
      instantiation_scn => :flashback_scn,
      apply_database_link => NULL);
  end if;
end;
/

-------------------------------
-- Setup Propagation
-------------------------------

--
-- Propagation from local queue to ORC1.WORLD
--
begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "COUNTRIES" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."COUNTRIES"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "DEPARTMENTS" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."DEPARTMENTS"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "EMPLOYEES" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."EMPLOYEES"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "JOBS" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."JOBS"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "JOB_HISTORY" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."JOB_HISTORY"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "LOCATIONS" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."LOCATIONS"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC1.WORLD' then
    --
    -- HR_REPG: Propagate "REGIONS" from local queue to ORC1
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."REGIONS"',
      streams_name => '&PROP_ORC1',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC1' ||
        '.' || '&QUEUE_ORC1' ||
        '@ORC1.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

--
-- Propagation from local queue to ORC2.WORLD
--
begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "COUNTRIES" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."COUNTRIES"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "DEPARTMENTS" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."DEPARTMENTS"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "EMPLOYEES" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."EMPLOYEES"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "JOBS" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."JOBS"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "JOB_HISTORY" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."JOB_HISTORY"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "LOCATIONS" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."LOCATIONS"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC2.WORLD' then
    --
    -- HR_REPG: Propagate "REGIONS" from local queue to ORC2
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."REGIONS"',
      streams_name => '&PROP_ORC2',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC2' ||
        '.' || '&QUEUE_ORC2' ||
        '@ORC2.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

--
-- Propagation from local queue to ORC3.WORLD
--
begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "COUNTRIES" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."COUNTRIES"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "DEPARTMENTS" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."DEPARTMENTS"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "EMPLOYEES" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."EMPLOYEES"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "JOBS" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."JOBS"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "JOB_HISTORY" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."JOB_HISTORY"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "LOCATIONS" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."LOCATIONS"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

begin
  if :local_db != 'ORC3.WORLD' then
    --
    -- HR_REPG: Propagate "REGIONS" from local queue to ORC3
    --
    dbms_streams_adm.add_table_propagation_rules(
      table_name => '"HR"."REGIONS"',
      streams_name => '&PROP_ORC3',
      source_queue_name => :local_queue_owner || '.' || :local_queue,
      destination_queue_name => '&QUEUE_OWNER_ORC3' ||
        '.' || '&QUEUE_ORC3' ||
        '@ORC3.WORLD',
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => :local_db);
  end if;
end;
/

-------------------------------
-- Setup Capture
-------------------------------
begin
  --
  -- HR_REPG : Add "COUNTRIES"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."COUNTRIES"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

begin
  --
  -- HR_REPG : Add "DEPARTMENTS"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."DEPARTMENTS"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

begin
  --
  -- HR_REPG : Add "EMPLOYEES"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."EMPLOYEES"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

begin
  --
  -- HR_REPG : Add "JOBS"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."JOBS"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

begin
  --
  -- HR_REPG : Add "JOB_HISTORY"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."JOB_HISTORY"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

begin
  --
  -- HR_REPG : Add "LOCATIONS"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."LOCATIONS"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

begin
  --
  -- HR_REPG : Add "REGIONS"
  --
  dbms_streams_adm.add_table_rules(
    table_name => '"HR"."REGIONS"',
    streams_type => 'CAPTURE',
    streams_name => '&CAPTURE_NAME',
    queue_name => :local_queue_owner || '.' || :local_queue,
    include_dml => TRUE,
    include_ddl => FALSE,
    include_tagged_lcr => FALSE,
    source_database => :local_db);
end;
/

-------------------------------
-- Setup Apply
-------------------------------
--
-- Setup Apply from ORC1.WORLD
--

begin
  --
  -- HR_REPG : Add "COUNTRIES" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."COUNTRIES"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "DEPARTMENTS" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."DEPARTMENTS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "EMPLOYEES" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."EMPLOYEES"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "JOBS" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."JOBS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "JOB_HISTORY" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."JOB_HISTORY"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "LOCATIONS" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."LOCATIONS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "REGIONS" to apply rules for apply from
  -- ORC1.WORLD
  --
  if(:local_db != 'ORC1.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."REGIONS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC1',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC1.WORLD');
  end if;
end;
/

--
-- Setup Apply from ORC2.WORLD
--

begin
  --
  -- HR_REPG : Add "COUNTRIES" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."COUNTRIES"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "DEPARTMENTS" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."DEPARTMENTS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "EMPLOYEES" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."EMPLOYEES"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "JOBS" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."JOBS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "JOB_HISTORY" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."JOB_HISTORY"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "LOCATIONS" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."LOCATIONS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "REGIONS" to apply rules for apply from
  -- ORC2.WORLD
  --
  if(:local_db != 'ORC2.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."REGIONS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC2',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC2.WORLD');
  end if;
end;
/

--
-- Setup Apply from ORC3.WORLD
--

begin
  --
  -- HR_REPG : Add "COUNTRIES" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."COUNTRIES"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "DEPARTMENTS" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."DEPARTMENTS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "EMPLOYEES" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."EMPLOYEES"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "JOBS" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."JOBS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "JOB_HISTORY" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."JOB_HISTORY"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "LOCATIONS" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."LOCATIONS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

begin
  --
  -- HR_REPG : Add "REGIONS" to apply rules for apply from
  -- ORC3.WORLD
  --
  if(:local_db != 'ORC3.WORLD') then
    dbms_streams_adm.add_table_rules(
      table_name => '"HR"."REGIONS"',
      streams_type => 'APPLY',
      streams_name => '&APPLY_ORC3',
      queue_name => :local_queue_owner || '.' || :local_queue,
      include_dml => TRUE,
      include_ddl => FALSE,
      include_tagged_lcr => FALSE,
      source_database => 'ORC3.WORLD');
  end if;
end;
/

-------------------------------
-- Add Supplemental Log Groups
-------------------------------
--
-- ** NOTE ** --
-- The primary key columns must be supplementally logged.
--
alter database add supplemental log data (primary key) columns;

--
-- ** NOTE ** --
-- The unique key columns must be supplementally logged.
--
alter database add supplemental log data (unique index) columns;

--
-- ** NOTE ** --
-- All the columns in a column group that is assigned an Oracle Streams
-- supported update conflict handler must be supplementally logged.
--

-- Supplementally log columns in column group 'COUNTRIES_TIMESTAMP_CG'
-- that is assigned the LATEST TIMESTAMP update conflict resolution method.
alter table "HR"."COUNTRIES" add supplemental log group COUNTRIES_LogGrp1 (
"COUNTRY_NAME"
,"REGION_ID"
,"TIMESTAMP"
);

-------------------------------
-- Setup Conflict Resolution
-------------------------------
--
-- ** WARNING ** --
-- Oracle Streams does not support LATEST TIMESTAMP
-- conflict resolution method.
-- Changing LATEST TIMESTAMP to MAXIMUM as
-- they handle the conflicts in a similar manner.
--
declare
  cols dbms_utility.name_array;
begin
  cols(1) := 'COUNTRY_NAME';
  cols(2) := 'REGION_ID';
  cols(3) := 'TIMESTAMP';
  dbms_apply_adm.set_update_conflict_handler(
    object_name => 'HR.COUNTRIES',
    method_name => 'MAXIMUM',
    resolution_column => 'TIMESTAMP',
    column_list => cols);
end;
/

-------------------------------
-- Verify Oracle Streams Setup
-------------------------------

-- Verify creation of queues
select * from dba_queues
 where name = upper(:local_queue)
   and owner = upper(:local_queue_owner)
   and queue_table = upper(:local_queue_table)
 order by name;

-- Verify creation of capture_process
select * from dba_capture
 where capture_name = upper('&CAPTURE_NAME');

-- Verify creation of apply processes
select * from dba_apply
 where apply_name IN (
       upper('&APPLY_ORC1'),
       upper('&APPLY_ORC2'),
       upper('&APPLY_ORC3') )
 order by apply_name;

-- Verify propagation processes
select * from dba_propagation
 where propagation_name IN (
       upper('&PROP_ORC1'),
       upper('&PROP_ORC2'),
       upper('&PROP_ORC3') )
 order by propagation_name;

-- Verify Oracle Streams rules
select * from dba_streams_table_rules
 where streams_name = upper('&CAPTURE_NAME');

select * from dba_streams_table_rules
 where streams_name IN (
       upper('&APPLY_ORC1'),
       upper('&APPLY_ORC2'),
       upper('&APPLY_ORC3') )
 order by source_database;

select * from dba_streams_table_rules
 where streams_name IN (
       upper('&PROP_ORC1'),
       upper('&PROP_ORC2'),
       upper('&PROP_ORC3') )
 order by source_database;

-- Do not resume Repcat activity once Oracle Streams is set up.
-- Drop all the repgroups that have been migrated to Oracle Streams.
-- Start apply and capture processes at all sites.