
SQL*Plus: Release 8.1.7.0.0 - Production on Fri Dec 6 14:57:27 2002

(c) Copyright 2000 Oracle Corporation.  All rights reserved.


Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production

SQL> spool c:\oracle\replication\master_group.sql
SQL> start create_master_group.sql
SQL> start create_master_group;
SQL> spool c:\create_master_group.sql
SQL> CONNECT repadmin/repadmin@militaer
Connected.
SQL> 
SQL> BEGIN
  2     DBMS_REPCAT.CREATE_MASTER_REPGROUP (
  3        gname => 'SCOTT_MG');
  4  END;
  5  /

PL/SQL procedure successfully completed.

SQL> 
SQL> -- /*************************************************************************
SQL> -- STEP 3:
SQL> -- ADD OBJECTS TO MASTER GROUP
SQL> -- *************************************************************************/
SQL> 
SQL> --Use the CREATE_MASTER_REPOBJECT API to add an object to your master group.
SQL> --In most cases, you probably will be adding tables to your master group,
SQL> --but you can also add indexes, procedures, views, synonyms, and so on.  See
SQL> --CREATE_MASTER_REPOBJECT procedure for additional
SQL> --information. 
SQL> 
SQL> BEGIN
  2     DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
  3        gname => 'SCOTT_MG',
  4        type => 'TABLE',
  5        oname => 'EMP',
  6        sname => 'SCOTT',
  7        use_existing_object => TRUE,
  8        copy_rows => TRUE);
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN
  2     DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
  3        gname => 'SCOTT_MG',
  4        type => 'TABLE',
  5        oname => 'dept',
  6        sname => 'SCOTT',
  7        use_existing_object => TRUE,
  8        copy_rows => TRUE);
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL> 
SQL> --The tables EMP and DEPT have a primary key, but BONUS and SALGRADE do not have 
SQL> --a primary key. For replication to work properly, each replicated table either 
SQL> --needs a primary key or to have a "set column." The 
SQL> --DBMS_REPCAT.SET_COLUMNS procedure is sufficient for multimaster replication 
SQL> --only, but if you also want to support fast refreshable snapshots, you need a 
SQL> --primary key. It is easier to alter your object before you add it to your 
SQL> --master group.
SQL> 
SQL> ALTER TABLE scott.bonus ADD (CONSTRAINT bonus_pk PRIMARY KEY(ename));

Table altered.

SQL> 
SQL> BEGIN
  2     DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
  3        gname => 'SCOTT_MG',
  4        type => 'TABLE',
  5        oname => 'bonus',
  6        sname => 'SCOTT',
  7        use_existing_object => TRUE,
  8        copy_rows => TRUE);
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL> 
SQL> --You must modify the SCOTT.SALGRADE object just as you altered the
SQL> --SCOTT.BONUS object in the previous step.
SQL> 
SQL> ALTER TABLE scott.salgrade ADD (CONSTRAINT salgrade_pk PRIMARY KEY(grade));
ALTER TABLE scott.salgrade ADD (CONSTRAINT salgrade_pk PRIMARY KEY(grade))
                                           *
ERROR at line 1:
ORA-02437: cannot validate (SCOTT.SALGRADE_PK) - primary key violated


SQL> 
SQL> BEGIN
  2     DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
  3        gname => 'SCOTT_MG',
  4        type => 'TABLE',
  5        oname => 'salgrade',
  6        sname => 'SCOTT',
  7        use_existing_object => TRUE,
  8        copy_rows => TRUE);
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL> 
SQL> -- /*************************************************************************
SQL> -- STEP 4:
SQL> -- ADD ADDITIONAL MASTER SITES
SQL> -- *************************************************************************/
SQL> 
SQL> --After you have defined your master group at the MASTERDEF site (the
SQL> --site where the master group was created becomes the MASTER DEFINITION
SQL> --site by default), you can define the other sites that will participate
SQL> --in the replicated environment. You might have guessed that you will be
SQL> --adding the ORC2.WORLD and ORC3.WORLD sites to our replicated environment.
SQL> 
SQL> --  BEGIN
SQL> --    DBMS_REPCAT.ADD_MASTER_DATABASE (
SQL> --    gname => 'SCOTT_MG',
SQL> --      master => 'ORC2.WORLD',
SQL> --      use_existing_objects => TRUE,
SQL> --      copy_rows => TRUE,
SQL> --      propagation_mode => 'ASYNCHRONOUS');
SQL> --END;
SQL> --/
SQL> 
SQL> /*************************************************************************
DOC>NOTE: You should wait until ORC2.WORLD appears in the DBA_REPSITES view
DOC>before continuing. Execute the following SELECT statement in another
DOC>SQL*Plus session to make sure that ORC2.WORLD has appeared):
DOC>
DOC>-- SELECT * FROM dba_repsites WHERE gname = 'SCOTT_MG';
DOC>--*************************************************************************/
SQL> -- PAUSE Press <RETURN> to continue.
SQL> BEGIN
  2     DBMS_REPCAT.ADD_MASTER_DATABASE (
  3        gname => 'SCOTT_MG',
  4        master => 'ORC3.WORLD',
  5        use_existing_objects => TRUE,
  6        copy_rows => TRUE,
  7        propagation_mode=> 'ASYNCHRONOUS');
  8  END;
  9  /
BEGIN
*
ERROR at line 1:
ORA-00439: feature not enabled: Advanced replication
ORA-06512: at "SYS.DBMS_SNAP_INTERNAL", line 267
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 1871
ORA-06512: at "SYS.DBMS_REPCAT", line 121
ORA-06512: at line 2


SQL> --/*************************************************************************
SQL> NOTE: You should wait until ORC3.WORLD appears in the DBA_REPSITES view
SP2-0734: unknown command beginning "NOTE: You ..." - rest of line ignored.
SQL> before continuing. Execute the following SELECT statement in another
SP2-0734: unknown command beginning "before con..." - rest of line ignored.
SQL> SQL*Plus session to make sure that ORC3.WORLD has appeared):
SP2-0734: unknown command beginning "SQL*Plus s..." - rest of line ignored.
SQL> 
SQL> SELECT * FROM dba_repsites WHERE gname = 'SCOTT_MG';

GNAME
------------------------------
DBLINK
--------------------------------------------------------------------------------
M S
- -
MASTER_COMMENT
--------------------------------------------------------------------------------
M PROP_UPDATES M GROUP_OWNER
- ------------ - ------------------------------
SCOTT_MG
MILITAER.LS.DE
Y

GNAME
------------------------------
DBLINK
--------------------------------------------------------------------------------
M S
- -
MASTER_COMMENT
--------------------------------------------------------------------------------
M PROP_UPDATES M GROUP_OWNER
- ------------ - ------------------------------

Y            0 Y PUBLIC


SQL> *************************************************************************/
SP2-0734: unknown command beginning " *********..." - rest of line ignored.
SQL> --PAUSE Press <RETURN> to continue.
SQL> 
SQL> /*************************************************************************
DOC>CAUTION:  If you added one or more tables to a master group during creation 
DOC>of the group, do not resume replication activity immediately. First consider 
DOC>the possibility of replication conflicts, and configure conflict resolution 
DOC>for the replicated tables in the group. See Chapter 6, "Conflict Resolution"  
DOC>for more information about configuring conflict resolution for master group 
DOC>objects.
DOC>*************************************************************************/
SQL> 
SQL> /*************************************************************************
DOC>STEP 5:
DOC>GENERATE REPLICATION SUPPORT
DOC>*************************************************************************/
SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'EMP', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'dept', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'bonus', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'salgrade', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /
BEGIN
*
ERROR at line 1:
ORA-23416: table "SCOTT"."SALGRADE" does not contain a primary key constraint
ORA-06512: at "SYS.DBMS_REPCAT_UTL3", line 2142
ORA-06512: at "SYS.DBMS_REPCAT_UTL3", line 4013
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 2614
ORA-06512: at "SYS.DBMS_REPCAT", line 703
ORA-06512: at line 2


SQL> 
SQL> /*************************************************************************
DOC>NOTE: You should wait until the DBA_REPCATLOG view is empty before
DOC>resuming master activity. Execute the following SELECT statement
DOC>to monitor your DBA_REPCATLOG view:
DOC>*************************************************************************/
SQL> 
SQL> SELECT * FROM dba_repcatlog WHERE gname = 'SCOTT_MG';

no rows selected

SQL> PAUSE Press <RETURN> to continue.
Press <RETURN> to continue.

SQL> /*************************************************************************
DOC>STEP 6:
DOC>RESUME REPLICATION
DOC>*************************************************************************/
SQL> 
SQL> --After you have completed creating your master group, adding replication
SQL> --objects, generating replication support, and adding additional master
SQL> --databases, you need to resume replication activity. The 
SQL> --RESUME_MASTER_ACTIVITY procedure API "turns on" replication for 
SQL> --the specified master group.
SQL> 
SQL> BEGIN 
  2     DBMS_REPCAT.RESUME_MASTER_ACTIVITY (
  3        gname => 'SCOTT_MG'); 
  4  END;
  5  /
BEGIN
*
ERROR at line 1:
ORA-23419: regenerate replication support before resuming master activity
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 3173
ORA-06512: at "SYS.DBMS_REPCAT", line 763
ORA-06512: at line 2


SQL> 
SQL> 
SQL> BEGIN 
  2     DBMS_REPCAT.RESUME_MASTER_ACTIVITY (
  3        gname => 'SCOTT_MG'); 
  4  END;
  5  /
BEGIN
*
ERROR at line 1:
ORA-23419: regenerate replication support before resuming master activity
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 3173
ORA-06512: at "SYS.DBMS_REPCAT", line 763
ORA-06512: at line 2


SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'EMP', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'dept', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'bonus', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'salgrade', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /
BEGIN
*
ERROR at line 1:
ORA-23308: object SCOTT.SALGRADE does not exist or is invalid
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 2559
ORA-06512: at "SYS.DBMS_REPCAT", line 703
ORA-06512: at line 2


SQL> BEGIN 
  2     DBMS_REPCAT.RESUME_MASTER_ACTIVITY (
  3        gname => 'SCOTT_MG'); 
  4  END;
  5  /
BEGIN
*
ERROR at line 1:
ORA-23419: regenerate replication support before resuming master activity
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 3173
ORA-06512: at "SYS.DBMS_REPCAT", line 763
ORA-06512: at line 2


SQL> 
SQL> BEGIN 
  2      DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
  3        sname => 'SCOTT',
  4        oname => 'salgrade', 
  5        type => 'TABLE',
  6        min_communication => TRUE); 
  7  END;
  8  /
BEGIN
*
ERROR at line 1:
ORA-23308: object SCOTT.SALGRADE does not exist or is invalid
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 2559
ORA-06512: at "SYS.DBMS_REPCAT", line 703
ORA-06512: at line 2


SQL> 