Previous |
Next |
When the site column has been created, you need to create a trigger that populates this column with the global name (Global Names) of the database when a row is either inserted or updated. This recorded value is used in the resolution of conflicts based on the site priority method.
The Execute DDL feature enables you to create a database object from within the replication interface. After you have created the object, add the object to your master group, which ensures that the object is created at all master sites.
Complete the following steps to create a site trigger:
Complete the steps in Before Configuring Conflict Resolution.
Complete the steps in Configuring Timestamp Resolution.
Return to the Master Groups page.
Select the target master group that contains the object for which you want to add the trigger.
Click the number in the Administrative Request column.
The Administrative Requests page appears.
Click Advanced to display, if required, the Enter DDL Text field.
Enter the DDL text in the Enter DDL Text field to create the trigger.
For example, suppose you had the following conditions for the trigger:
You want to call the trigger ORD_TRIG
.
The trigger is in the OE
schema on the ORDERS
table.
The site column name is SITE_PRIORITY
.
Given these conditions, enter the following to create the trigger:
CREATE TRIGGER oe.site_trig BEFORE INSERT OR UPDATE ON oe.orders FOR EACH ROW BEGIN IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN :NEW.site_priority := DBMS_REPUTIL.GLOBAL_NAME; END IF; END;
From the Execute At list, select the master sites where you want to create the object.
Because you are replicating this trigger, you can simply select the master definition site. When you add this trigger to your master group, it is created automatically at all master sites participating in the master group.
Click Execute.
Return to Master Groups page.
Click Edit.
The Edit Master Group page appears.
Click Objects.
The Objects subpage of the Edit Master Group page appears.
Click Add.
The Add Objects page appears.
Select Trigger from the Object Types list and select the schema in which you created your trigger from the Schema list.
Click OK.
The Objects subpage of the Edit Master Group page reappears.
Locate and select the site trigger that you just created from the Name list.
Select Use Existing Object for the new trigger if the trigger exists at the other master sites. In this case, the existing trigger is used at the other master sites.
If a trigger of the same name exists but is not exactly the same and the Use Existing Object box is enabled, you receive an error when adding the trigger to your master group.
If the trigger does not exist at the other master sites, the trigger is created at the other sites regardless of this box setting.
Select Copy Row Data for the new trigger.
Click Apply.