14.4 DBMS_REPCAT: Managing Snapshot Replication GroupsAlthough most of the procedures in the DBMS_REPCAT package are used to create and maintain the advanced replication environment, some of the procedures let you manipulate snapshot replication groups. This section describes only the snapshot-related programs. The bulk of the DBMS_REPCAT programs are described in Chapters 15 and 16. The procedures in DBMS_REPCAT used for manipulating snapshot replication groups are in large measure analogous to the procedures DBMS_REFRESH provides for manipulating simple snapshot groups. 14.4.1 Getting Started with DBMS_REPCATThe DBMS_REPCAT package is created when the Oracle database is installed. The dbmsrepc.sql script (found in the built-in packages source directory, as described in Chapter 1 ) contains the source code for this package's specification. This script is called by catrep.sql , which must be run to install the advanced replication packages. The script creates the public synonym DBMS_REPCAT. The package procedure DBMS_REPCAT_AUTH.GRANT_SURROGATE_REPCAT grants EXECUTE privileges on the package to the specified grantee. In addition, the package owner (SYS) and users with the EXECUTE ANY PROCEDURE system privilege may execute it. 14.4.1.1 DBMS_REPCAT programsTable 14.5 lists only the DBMS_REPCAT snapshot-related programs; see Tables 15-3 and 16-10 for the remaining DBMS_REPCAT programs.
14.4.1.2 DBMS_REPCAT exceptionsDBMS_REPCAT defines the following exceptions for the programs listed in Table 14.6 .
14.4.2 Creating and Dropping Snapshot Replication GroupsThe CREATE_SNAPSHOT_REPGROUP and DROP_SNAPSHOT_REPGROUP procedures allow you to create and destroy snapshot replication groups. 14.4.2.1 The DBMS_REPCAT. CREATE_SNAPSHOT_REPGROUP procedureThis procedure creates a new, empty snapshot replication group. You must invoke it from the snapshot site. The program specification follows: PROCEDURE DBMS_REPCAT.CREATE_SNAPSHOT_REPGROUP (gname IN VARCHAR2, master IN VARCHAR2, comment IN VARCHAR2 := '', propagation_mode IN VARCHAR2 := 'ASYNCHRONOUS'); Parameters are summarized in the following table.
14.4.2.1.1 ExceptionsThe CREATE_SNAPSHOT_REPGROUP procedure raises the following exceptions:
14.4.2.1.2 RestrictionsNote the following restrictions on calling CREATE_SNAPSHOT_REPGROUP:
14.4.2.2 The offline snapshot instantiation procedureThe procedure for performing offline instantiation of snapshots in an advanced replication environment (using the CREATE SNAPSHOT command and the DBMS_OFFLINE_SNAPSHOT and DBMS_REPCAT packages) follows:
CREATE SNAPSHOT snp_countries AS SELECT * FROM countries@D7CA.BIGWHEEL.COM@TCPIP
14.4.2.3 The DBMS_REPCAT.DROP_SNAPSHOT_REPGROUP procedureThe DBMS_REPCAT package's DROP_SNAPSHOT_REPGROUP procedure is the counterpart to the CREATE_SNAPSHOT_REPGROUP procedure. As you would suspect, this procedure drops an existing snapshot replication group, and optionally, all member snapshots. Here's the specification: PROCEDURE DBMS_REPCAT>DROP_SNAPSHOT_REPGROUP (gname IN VARCHAR2, drop_contents IN BOOLEAN := FALSE); Parameters are summarized in the following table.
14.4.2.3.1 ExceptionsThe DROP_SNAPSHOT_REPGROUP procedure raises the following exceptions:
14.4.2.3.2 RestrictionsIf drop_contents is set to FALSE, the triggers created to support snapshot modifications remain. 14.4.2.3.3 ExampleThe following example illustrates the dropping of a snapshot replication group with the DROP_SNAPSHOT_REPGROUP procedure: BEGIN DBMS_REPCAT.DROP_SNAPSHOT_REPGROUP( gname => 'SPROCKET', drop_objects => TRUE); END; Here, we drop the snapshot replication group SPROCKET and drop the member snapshots as well. 14.4.3 Adding and Removing Snapshot Replication Group ObjectsThe CREATE_SNAPSHOT_REPOBJECT and DROP_SNAPSHOT_REPOBJECT procedures add and remove objects, respectively, from a snapshot replication group. These objects may be snapshots, packages, package bodies, procedures, synonyms, or views. 14.4.3.1 The DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT procedureThe CREATE_SNAPSHOT_REPOBJECT procedure adds an object to a snapshot replication group. For new snapshot objects, this procedure generates row-level replication triggers for snapshots if the master table uses row-level replication. The specifications differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT. CREATE_SNAPSHOT_REPOBJECT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, ddl_text IN VARCHAR2 := '', comment IN VARCHAR2 := '', gname IN VARCHAR2 := '', gen_objs_owner IN VARCHAR2 := ''); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, ddl_text IN VARCHAR2 := '', comment IN VARCHAR2 := '', gname IN VARCHAR2 := '', gen_objs_owner IN VARCHAR2 := '', min_communication IN BOOLEAN := TRUE);
Parameters are summarized in the following table.
14.4.3.1.1 Exceptions.CREATE_SNAPSHOT_REPGROUP raises the following exceptions:
14.4.3.1.2 ExampleThe following example illustrates how to add an object to an existing snapshot replication group: BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT( sname => 'SPROCKET', oname => 'PRICE_LIST', type => 'SNAPSHOT' , ddl_text=> 'CREATE SNAPSHOT SPROCKET.PRICES AS SELECT * FROM PRICES@D7CA.BIGWHEEL.COM' , gnam => 'SPROCKET', gen_objs_owner => 'SPROCKET') END; BEGIN 14.4.3.2 The DBMS_REPCAT.DROP_SNAPSHOT_REPOBJECT procedureThe DROP_SNAPSHOT_REPOBJECT procedure drops an object from a snapshot replication group. PROCEDURE DBMS_REPCAT.DROP_SNAPSHOT_REPOBJECT (sname IN VARCHAR2, oname IN VARCHAR2, type IN VARCHAR2, drop_objects IN BOOLEAN := FALSE);. For parameter descriptions, see the table in the Section 14.4.3.1, "The DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT procedure" " section. 14.4.3.2.1 ExceptionsDROP_SNAPSHOT_REPOBJECT raises the following exceptions:
14.4.3.2.2 RestrictionsIf the type parameter in DROP_REPOBJECT is SNAPSHOT and you do not set the drop_objects parameter to TRUE, replication triggers and associated packages remain in the schema, and deferred transactions (if any) remain in the DEFTRANS queue. 14.4.3.2.3 ExampleThe following example drops an object from a snapshot replication group: DBMS_REPCAT.FTOP_SNAPSHOT_REPOBJECT( sname => 'SPROCKET', oname => 'PRICE_LIST', type => 'SNAPSHOT', drop_objects=> TRUE); END; 14.4.4 Altering a Snapshot Replication Group's Propagation ModeThe ALTER_SNAPSHOT_PROPAGATION procedure changes a snapshot replication group's propagation mode. The propagation mode can be either SYNCHRONOUS or ASYNCHRONOUS. When you call this procedure, Oracle does the following:
14.4.4.1 The DBMS_REPCAT.ALTER_SNAPSHOT_PROPAGATION procedureCall the ALTER_SNAPSHOT_PROPAGATION procedure to change the propagation mode of a particular snapshot. Specifications for Oracle7 and Oracle8 differ as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT.ALTER_SNAPSHOT_PROPAGATION (alter_snapshot_propagation( gname IN VARCHAR2, propagation_mode IN VARCHAR2, comment IN VARCHAR2 := '', execute_as_user IN BOOLEAN := FALSE); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.ALTER_SNAPSHOT_PROPAGATION (gname IN VARCHAR2, propagation_mode IN VARCHAR2, comment IN VARCHAR2 := '' ); Parameters are summarized in the following table.
14.4.4.1.1 ExceptionsALTER_SNAPSHOT_PROPAGATION raises the following exceptions:
14.4.4.1.2 RestrictionsALTER_SNAPSHOT_PROPAGATION must be called from a snapshot site. 14.4.4.1.3 ExampleThe following example shows how to switch from asynchronous to synchronous propagation for a given snapshot replication group: BEGIN DBMS_REPCAT.ALTER_SNAPSHOT_PROPAGATION( gname => 'SPROCKET', propagation_mode => 'ASYNCHRONOUS', comment => 'Mode set to asynchronous on ' ||sysdate|| 'by '||user); END; 14.4.5 Manually Refreshing a Snapshot Replication GroupYou can use the REFRESH_SNAPSHOT_REPGROUP to refresh manually a snapshot replication group. The procedure can optionally drop objects that are no longer in the group, and/or refresh the snapshots and other objects.
14.4.5.1 The DBMS_REPCAT.REFRESH_SNAPSHOT_REPGROUP procedureCall the DBMS_REPCAT.REFRESH_SNAPSHOT_REPGROUP procedure to refresh a snapshot replication group manually. Specifications differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REPCAT.REFRESH_SNAPSHOT_REPGROUP (gname IN VARCHAR2, drop_missing_contents IN BOOLEAN := FALSE, refresh_snapshots IN BOOLEAN := FALSE, refresh_other_objects IN BOOLEAN := FALSE, execute_as_user IN BOOLEAN:= FALSE); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.REFRESH_SNAPSHOT_REPGROUP (gname IN VARCHAR2, drop_missing_contents IN BOOLEAN := FALSE, refresh_other_objects IN BOOLEAN := FALSE ) Parameters are summarized in the following table.
14.4.5.1.1 ExceptionsREFRESH_SNAPSHOT_REPGROUP raises the following exceptions:
14.4.5.1.2 RestrictionsREFRESH_SNAPSHOT_REPGROUP must be called from a snapshot site. 14.4.5.1.3 ExampleThe following example illustrates how REFRESH_SNAPSHOT_REPGROUP is commonly used: BEGIN DBMS_REPCAT.REFRESH_SNAPSHOT_REPGROUP( gname => 'SPROCKET', drop_missing_contents => TRUE, refresh_snapshots => TRUE, refresh_other_objects => TRUE) END; This example refreshes all snapshots in group SPROCKET, drops schema objects that are no longer in the group, and recreates any views, procedures, or synonyms that have been created or altered at the master site. 14.4.6 Switching the Master of a Snapshot Replication GroupShould it ever become necessary to point a snapshot replication group to a different master site, you can do it with the SWITCH_SNAPSHOT_MASTER procedure. 14.4.6.1 The DBMS_REPCAT.SWITCH_SNAPSHOT_MASTER procedureThe SWITCH_SNAPSHOT_MASTER procedure lets you switch a snapshot replication group to a different master site. This procedure changes the master site for the specified snapshot group. The new master site must contain a replica of the replication group gname. The next time the snapshot group refreshes, Oracle performs a full refresh. The specifications for SWITCH_SNAPSHOT_MASTER differ for Oracle7 and Oracle8 as follows. Here is the Oracle7 specification: PROCEDUREDBMS_REPCAT.SWITCH_SNAPSHOT_MASTER (gname IN VARCHAR2 := '', master IN VARCHAR2, execute_as_user IN BOOLEAN = FALSE, sname IN VARCHAR2 := ''); Here is the Oracle8 specification: PROCEDURE DBMS_REPCAT.SWITCH_SNAPSHOT_MASTER (gname IN VARCHAR2 := '', master IN VARCHAR2) Parameters are summarized in the following table.
14.4.6.1.1 ExceptionsThe SWITCH_SNAPSHOT_MASTER procedure may raise the following exceptions:
14.4.6.1.2 RestrictionsNote the following restrictions on calling SWITCH_SNAPSHOT_MASTER:
14.4.6.1.3 ExampleThe following call remasters snapshot group SPROCKET to D7NY.BIGWHEEL.COM: BEGIN DBMS_REPCAT.SWITCH_SNAPSHOT_MASTER( gname => 'SPROCKET', master => 'D7NY.BIGWHEEL.COM') END
Figure Figure 14.3 graphically illustrates this example. Figure 14.3: Using DBMS_REPCAT.SWITCH_SNAPSHOT_MASTERCopyright (c) 2000 O'Reilly & Associates. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|