Setting up non-transactional replication for sibling tables or subsets of tables
The view must always contain the RowPointer and primary key columns.
When an update occurs to a base table, and some columns from that base table are included in a view defined in Replication Categories, the view is checked to see if any of the matching columns in the view have been updated. If only updates to columns not in the view occur, then nothing is replicated.
To join the customer_mst and custaddr_mst base tables together into a single SuperCustomer output table, perform these actions:
- Make a view called
SuperCustomerView that contains a RowPointer column tied to the custaddr_mst.RowPointer. All columns in the
primary key of the base table must be included in the view.
This view must point directly to the custaddr_mst table, not to a view over the custaddr_mst table. The logic used to generate the replication triggers needs the actual base table. Since the _mst table (a base table) is used, a filter on the site_ref column is also required. For example:
CREATE VIEW dbo.SuperCustomerView AS SELECT custaddr.cust_num - primary key column , custaddr.cust_seq - primary key column , custaddr.site_ref - primary key column , custaddr.name , custaddr.city ...… , custaddr.RowPointer , customer.contact##1 , customer.contact##2 FROM custaddr_mst custaddr INNER JOIN customer_mst customer ON customer.cust_num = custaddr.cust_num AND customer.cust_seq = custaddr.cust_seq WHERE custaddr.site_ref = dbo.DefaultToLocalSite(NULL) - filter on current site data and customer.site_ref = dbo.DefaultToLocalSite(NULL) - filter on current site data
- Make a new category with these object category rows:
Grid column Object row 1 Object row 2 Object Name customer_mst custaddr_mst Object Type TABLE TABLE Filter Skip Insert Yes Skip Update Skip Delete Yes Skip Method To Object Name SuperCustomer SuperCustomer Insert From View SuperCustomerView SuperCustomerView The insert view name is needed on the customer object, even though no insert actually occurs on INSERT, because the view is used to determine which columns being updated need to be replicated.
After you regenerate the replication trigger code, the following scenarios would occur.
On an INSERT of a customer record:
- The customer_mst record is inserted.
- The customer_mstIup trigger inserts a custaddr_mst record.
- The custaddr_mstIupReplicate trigger inserts ShadowValues row to SuperCustomer and selects columns from SuperCustomerView.
- The customer_mstIupReplicate trigger does not send an insert.
On an UPDATE of a customer record:
- The customer_mst record is updated.
- The customer_mstIupReplicate trigger sends the update to SuperCustomer.
On an UPDATE of the custaddr_mst table:
- The custaddr_mst record is updated.
- The custaddr_mstIupReplicate trigger sends the update to SuperCustomer.
On a DELETE of a customer record:
- The customer_mstDel trigger deletes the custaddr_mst record.
- The custaddr_mstDelReplicate trigger sends the deletion to SuperCustomer.
- The customer_mstDelReplicate trigger does not send a deletion.