Oracle7 Server Distributed Systems Volume II: Replicated Data

Contents Index Home Previous Next

Using Priority Groups

To use the priority group method to resolve update conflicts, first create a priority group, then add this conflict resolution method for a column group. To create a priority group, do the following:

A single priority group can be used by multiple tables. Therefore, the name that you select for your priority group must be unique within a replicated object group. The column corresponding to this priority group can have different names in different tables.

You must indicate which column in a table is associated with a particular priority group when you add the priority group conflict resolution routine for the table. The priority group must therefore contain all possible values for all columns associated with that priority group.

For example, suppose that you had a table, INVENTORY, with a column of type VARCHAR2, STATUS, that could have three possible values: ORDERED, SHIPPED, and BILLED. Now suppose that you want to resolve update conflicts based upon the value of this STATUS column.

Your procedure calls would look similar to those shown below.

DBMS_REPCAT.MAKE_COLUMN_GROUP(
	sname	=>	'acct', 
	oname	=>	'inventory',
	column_group	=>	'all', 
	list_of_column_names	=>	'*');
DBMS_REPCAT.DEFINE_PRIORITY_GROUP(
	sname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	datatype 	=> 	'varchar2');
DBMS_REPCAT.ADD_PRIORITY_VARCHAR2(
	sname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	value 	=> 	'ordered', 
	priority 	=> 	1);
DBMS_REPCAT.ADD_PRIORITY_VARCHAR2(
	sname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	value 	=> 	'shipped', 
	priority 	=> 	2);
DBMS_REPCAT.ADD_PRIORITY_VARCHAR2(
	sname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	value 	=> 	'billed',
	priority 	=> 	3);
DBMS_REPCAT.ADD_UPDATE_RESOLUTION(
	sname	=>	'acct',
	oname	=>	'inventory',
	column_group	=>	'all',
	sequence_no	=>	1,
	method	=>	'PRIORITY_GROUP',
	parameter_column_name =>	'status');

The next several sections describe how to manage priority groups.

Creating a Priority Group

Use the DEFINE_PRIORITY_GROUP procedure in the DBMS_REPCAT package to create a new priority group for a replicated object group, as shown in the following example:

DBMS_REPCAT.DEFINE_PRIORITY_GROUP(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	datatype 	=> 	'varchar2');

This example creates a priority group called STATUS for the ACCT object group. The members of this priority group will have values of type VARCHAR2.

You must call this procedure from the master definition site. The member is not added to the priority group until you call the procedure GENERATE_REPLICATION_SUPPORT for any table in the object group (since there is no group-level equivalent for this command).

Additional Information: The parameters for the DEFINE_PRIORITY_GROUP procedure are described in Table 12 - 111, and the exceptions are listed in Table 12 - 112.

Adding Members to a Priority Group

There are several different procedures in the DBMS_REPCAT package for adding members to a priority group. These procedures are of the form ADD_PRIORITY_type, where type is equivalent to the datatype that you specified when you created the priority group:

The procedure that you must call is determined by the datatype of your "priority" column. You must call this procedure once for each of the possible values of the "priority" column.

You must call this procedure from the master definition site. The value is synchronously available at the master definition site, but is not available at any other master sites until you run GENERATE_REPLICATION_SUPPORT. If you are modifying a priority group that is already in use, call the procedures in the following order to ensure proper resolution of conflicts:

The following example adds the value SHIPPED to the STATUS priority group:

DBMS_REPCAT.ADD_PRIORITY_VARCHAR2(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	value 	=> 	'shipped', 
	priority 	=> 	2);

Additional Information: The parameters for the ADD_PRIORITY_type procedures are described in Table 12 - 66, and the exceptions are listed in Table 12 - 67.

Altering the Value of a Member

There are several different procedures in the DBMS_REPCAT package for altering the value of a member of a priority group. These procedures are of the form ALTER_PRIORITY_type, where type is equivalent to the datatype that you specified when you created the priority group:

The procedure that you must call is determined by the datatype of your "priority" column. Because a priority group member consists of a priority associated with a particular value, these procedures enable you to change the value associated with a given priority level.

You must call this procedure from the master definition site. The value is synchronously available at the master definition site, but is not available at any other master sites until you run GENERATE_REPLICATION_SUPPORT. If you are modifying a priority group that is already in use, call the procedures in the following order to ensure proper resolution of conflicts:

You must call this procedure from the master definition site. The value of the member is not altered until you call the procedure GENERATE_REPLICATION_SUPPORT for any table in the object group (since there is no group-level equivalent for this command).

The following example changes the recognized value of items at priority level 2 from SHIPPED to IN_SHIPPING:

DBMS_REPCAT.ALTER_PRIORITY_VARCHAR2(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	old_value 	=> 	'shipped', 
	new_value 	=> 	'in_shipping');

Additional Information: The parameters for the ALTER_PRIORITY_type procedures are described in Table 12 - 78, and the exceptions are listed in Table 12 - 79.

Altering the Priority of a Member

Use the ALTER_PRIORITY procedure in the DBMS_REPCAT package to alter the priority level associated with a given priority group member. Because a priority group member consists of a priority associated with a particular value, this procedure lets you raise or lower the priority of a given column value. Members with higher priority values are given higher priority when resolving conflicts.

You must call this procedure from the master definition site. The priority level of the member is not altered until you call the procedure GENERATE_REPLICATION_SUPPORT for any table in the object group (since there is no group-level equivalent for this command).

The following example changes the priority of items marked as IN_SHIPPING from level 2 to level 4:

DBMS_REPCAT.ALTER_PRIORITY(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status', 
	old_priority 	=> 	2, 
	new_priority 	=> 	4);

Additional Information: The parameters for the ALTER_PRIORITY procedure are described in Table 12 - 76, and the exceptions are listed in Table 12 - 77.

Dropping a Member by Value

There are several different procedures in the DBMS_REPCAT package for dropping a member of a priority group by value. These procedures are of the form DROP_PRIORITY_type, where type is equivalent to the datatype that you specified when you created the priority group:

The procedure that you must call is determined by the datatype of your "priority" column.

You must call this procedure from the master definition site. The member is not actually removed from the priority group until you call the procedure GENERATE_REPLICATION_SUPPORT for any table in the object group (since there is no group-level equivalent for this command).

In the following example, IN_SHIPPING is no longer a valid state for items in the STATUS priority group:

DBMS_REPCAT.DROP_PRIORITY_VARCHAR2(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status',
	value 	=> 	'in_shipping');

Additional Information: The parameters for the DROP_PRIORITY_type procedures are described in Table 12 - 129, and the exceptions are listed in Table 12 - 130.

Dropping a Member by Priority

Use the DROP_PRIORITY procedure in the DBMS_REPCAT package to drop a member of a priority group by priority level.

You must call this procedure from the master definition site. The member is not actually removed from the priority group until you call the procedure GENERATE_REPLICATION_SUPPORT for any table in the object group (since there is no group-level equivalent for this command).

In the following example, IN_SHIPPING (which was assigned to priority level 4) is no longer a valid state for items in the STATUS priority group:

DBMS_REPCAT.DROP_PRIORITY(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status',
	priority_num 	=> 	4);

Additional Information: The parameters for the DROP_PRIORITY procedure are described in Table 12 - 125, and the exceptions are listed in Table 12 - 126.

Dropping a Priority Group

Use the DROP_PRIORITY_GROUP procedure in the DBMS_REPCAT package to drop a priority group for a given replicated object group, as shown in the following example:

DBMS_REPCAT.DROP_PRIORITY_GROUP(
	gname 	=> 	'acct', 
	pgroup 	=> 	'status');

In this example, STATUS is no longer a valid priority group.

Attention: Before calling this procedure, you must call the DROP_UPDATE_RESOLUTION procedure for any column groups in the replicated object group that are using the PRIORITY GROUP conflict resolution method with this priority group. You can determine which column groups are affected by querying the RepResolution view.

You must call this procedure from the master definition site. The priority group is not actually dropped until you call the procedure GENERATE_REPLICATION_SUPPORT for any table in the object group (since there is no group-level equivalent for this command).

Additional Information: The parameters for the DROP_PRIORITY_GROUP procedure are described in Table 12 - 127, and the exceptions are listed in Table 12 - 128.


Contents Index Home Previous Next