SQL Remote User's Guide
A Tutorial for Adaptive Server Enterprise Users
Tutorial: Adaptive Server Enterprise replication
Setting up the consolidated database
The remaining task is to define the data to be replicated. To do this, you must first create a publication, which defines the available data, and then create a subscription for field_user, which defines the data that user is sharing.
In Adaptive Server Enterprise, they are created with the sp_create_publication procedure, which creates an empty publication, and the sp_add_article procedure, which adds articles to the procedure. Also, each table must be marked for replication before it can be included in a publication.
To create the publication
Create an empty publication:
exec sp_create_publication SalesRepData go
Mark both the SalesRep table and the Customer table for publication:
exec sp_add_remote_table SalesRep go exec sp_add_remote_table Customer go
Add the whole SalesRep table to the SalesRepData publication:
exec sp_add_article SalesRepData, SalesRep go
Add the Customer table to the SalesRepData publication, using the rep_key column to partition the table. The following statement should be typed all on one line, except for the go
:
exec sp_add_article SalesRepData, Customer, NULL, 'rep_key' go
Each user ID that is to receive changes to a publication must have a subscription to that publication. Subscriptions can only be created for a valid remote user. You need to add a subscription to the SalesRepData publication for the remote database user field_user.
To create a subscription
Create a subscription to SalesRepData for field_user, with a subscription value of rep1:
exec sp_subscription 'create', SalesRepData, field_user, 'rep1' go
At this stage, the subscription is not started—that is, no data will be exchanged. The subscription is started by the database extraction utility.