14.4.2.1.1 ExceptionsThe CREATE_SNAPSHOT_REPGROUP procedure raises the following exceptions: Name Number Description commfailure −23317 Unable to communicate with master dbnotcompatible
Trang 114.4.2.1.1 Exceptions
The CREATE_SNAPSHOT_REPGROUP procedure raises the following exceptions:
Name Number Description
commfailure −23317 Unable to communicate with master
dbnotcompatible −23375 Attempt to use SYNCHRONOUS propagation in pre−7.3 database
duplicaterepgroup −23374 Replication group gname already exists
nonmaster −23312 The master parameter is not a master site
norepoption −23364 Replication option not installed
typefailure −23319 propagation_mode not specified correctly
14.4.2.1.2 Restrictions
Note the following restrictions on calling CREATE_SNAPSHOT_REPGROUP:
•
You must be connected to the replication administrator account (typically REPADMIN) to call the CREATE_SNAPSHOT_REPGROUP procedure
•
The snapshot group name must match the name of the master replication group
14.4.2.2 The offline snapshot instantiation procedure
The 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:
1
Create a snapshot log for each master table if one does not already exist
2
Create a snapshot of each master table in the master database, and in the same schema as the master
table Of course, the name of the snapshot will have to be different from the name of the master table.
The CREATE SNAPSHOT statement must also include a loopback database link qualifier
CREATE SNAPSHOT snp_countries
AS SELECT * FROM countries@D7CA.BIGWHEEL.COM@TCPIP
3
Perform user exports of all schema that own master tables You should be logged on to the schema owner account for these exports The only tables that you need to export are the snapshot base
tables −− that is, those whose names begin with "SNAP$_"
4
Copy the export dump file(s) to the new snapshot site(s)
5
Use CREATE_SNAPSHOT_REPGROUP at the snapshot sites to create a new snapshot replication object group The name of this object group should be the same as the name of the replication group
of which the master tables are members
14.4.2 Creating and Dropping Snapshot Replication Groups 631
Trang 2BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPGROUP(
gname => 'SPROCKET', master => 'D7CA.BIGWHEEL.COM', comment => 'Group created on '||sysdate|| ' by '||user, propagation_mode=> 'ASYNCHRONOUS');
END;
6
Call DBMS_OFFLINE_SNAPSHOT.BEGIN_LOAD to begin loading the data from the export
file(s) You must call the procedure for every snapshot you plan to import
BEGIN DBMS_OFFLINE_SNAPSHOT.BEGIN_LOAD(
gname => 'SPROCKET', sname => 'SPROCKET', master_site => 'D7CA.BIGWHEEL.COM' snapshot_oname => 'SNP_COUNTRIES' storage_c => 'TABLESPACE sprocket_data STORAGE (INITIAL 64K)' comment => 'Load of COUNTRIES snapshot begun at '||sysdate); END;
7
Import the snapshot base table(s) from the export file(s) created in step 4
8
Call DBMS_OFFLINE_SNAPSHOT.END_LOAD for each snapshot when the load is complete
BEGIN DBMS_OFFLINE_SNAPSHOT.END_LOAD(
gname => 'SPROCKET' sname => 'SPROCKET' snapshot_oname => 'SNP_COUNTRIES');
END;
14.4.2.3 The DBMS_REPCAT.DROP_SNAPSHOT_REPGROUP procedure
The 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
Name Description
gname Name of the snapshot group
drop_contents If TRUE, objects in gname are dropped If FALSE (the default) they are simply no longer
replicated
14.4.2.3.1 Exceptions
The DROP_SNAPSHOT_REPGROUP procedure raises the following exceptions:
Name Number Description
missingrepgroup −23373 Replication group gname does not exist
14.4.2 Creating and Dropping Snapshot Replication Groups 632
Trang 3nonmaster −23313 Calling site is not a snapshot site
14.4.2.3.2 Restrictions
If drop_contents is set to FALSE, the triggers created to support snapshot modifications remain
14.4.2.3.3 Example
The 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 Objects
The 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 procedure
The 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);
NOTE: The only difference between the Orace7 and Oracle8 implementations is the addition
of the min_communication parameter in Oracle8
Parameters are summarized in the following table
14.4.2 Creating and Dropping Snapshot Replication Groups 633
Trang 4Name Description
sname Name of schema to which oname belongs
oname Name of object to be added
type Object type Supported types are PACKAGE, PACKAGE BODY, PROCEDURE,
SNAPSHOT, SYNONYM, and VIEW
ddl_text DDL used to create object (for type SNAPSHOT only)
comment Comment on object, visible in DBA_REPOBJECT data dictionary view
gname Name of snapshot group to which object is being added Defaults to sname if not
specified
gen_objs_owner Name of the schema in which to create the generated trigger and trigger package or
procedure wrapper for the object Defaults to sname
drop_objects If set to TRUE, object is dropped too If FALSE (the default), object is only removed
from the snapshot group
min_communication
(Oracle8 only)
Must be FALSE if any master site is running Oracle7 TRUE, the default setting, uses the minimum communication algorithm
14.4.3.1.1 Exceptions.
CREATE_SNAPSHOT_REPGROUP raises the following exceptions:
commfailure −23317 Unable to communicate with master site
ddlfailure −23318 Unable to perform DDL
duplicateobject −23309 Object oname already exists
missingobject −23308 Object oname does not exist in master's replication group gname
missingremoteobject −23381 Master site has not generated replication support for oname
missingschema −23306 Schema sname does not exist
misssnapobject −23355 Object oname does not exist at master
nonmaster −23312 Master site associated with snapshot group is no longer a master site
nonsnapshot −23314 Calling site is not a snapshot site
typefailure −23319 Invalid value for type
NOTE: CREATE_SNAPSHOT_REPOBJECT is called from the replication administrator
(typically REPADMIN) account If you are creating an snapshot with ddl_text, be sure to
specify the schema in which it should be created (if other than the replication administrator
account)
14.4.3.1.2 Example
The 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
14.4.3 Adding and Removing Snapshot Replication Group Objects 634
Trang 5PRICES@D7CA.BIGWHEEL.COM' ,
gnam => 'SPROCKET',
gen_objs_owner => 'SPROCKET')
END;
BEGIN
14.4.3.2 The DBMS_REPCAT.DROP_SNAPSHOT_REPOBJECT procedure
The 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 Exceptions
DROP_SNAPSHOT_REPOBJECT raises the following exceptions:
Name Number Description
missingobject −23308 Object oname does not exist in master's replication group gname
nonsnapshot −23314 Calling site is not a snapshot site
typefailure −23319 Invalid value for type
14.4.3.2.2 Restrictions
If 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 Example
The 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 Mode
The 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:
•
Pushes any transactions that exist in the deferred RPC queue for the group
•
14.4.3 Adding and Removing Snapshot Replication Group Objects 635