MobiLink Synchronization User's Guide
Adaptive Server Anywhere Clients
Adaptive Server Anywhere 7.0 MobiLink clients were configured using SQL statements that are now deprecated. In particular, synchronization definitions were used instead of publications and subscriptions. The older statements are no longer supported. They have some disadvantages:
A synchronization definition is equivalent to a single publication and a single subscription to it. There is no support for subscriptions to multiple publications. In contrast, a single MobiLink user can now subscribe to multiple publications. This allows you to synchronize some portions of your data without synchronizing all of it.
Some people found the old terminology confusing. For example, a MobiLink user ID was formerly called a site in the context of an Adaptive Server Anywhere client. A MobiLink user is now called a MobiLink user or a synchronization user.
The new statements are analogous to those used in SQL Remote, the Sybase message-based replication technology.
You can choose to synchronize all or any portion of the data in a client Adaptive Server Anywhere database. You can choose to synchronize entire tables, or you can choose to synchronize only particular columns and rows.
The synchronization definition, located in the client Adaptive Server Anywhere database, describes the data that is to be replicated and the location of the appropriate MobiLink synchronization server.
Synchronization scripts, stored in the consolidated database, control how the uploaded rows are processed and which rows are downloaded to the remote database. These scripts do not depend on the type of remote database.
A synchronization definition may include data from several database tables. Each table's contribution to a synchronization definition is called an article . Each article may consist of a whole table, or a subset of the rows and columns in a table.
Once a remote database is set up, the two databases must be periodically brought to a state where they both have the same set of information. This process of synchronization is carried out using the dbmlsync command line utility.
A table, once added to a synchronization definition, should not be altered. Altering the table interferes with the synchronization process. Should it be necessary to make such an alteration, this step should be performed immediately following synchronization.
The only way to ensure that the ALTER STATEMENT is executed immediately following synchronization is to place this statement in a script, then execute that script using the -i
option of the dbmlsync command line utility.
If you have developed UltraLite applications for use as MobiLink clients, the following information may be helpful. Many of the elements of a synchronization definition have an UltraLite counterpart.
Adaptive Server Anywhere 9.0 client | Adaptive Server Anywhere 7.0 client | UltraLite clients | MobiLink synchronization server |
---|---|---|---|
MobiLink synchronization user | site | user name | MobiLink user |
type | type | stream | connection type |
address | address | connection parameters | the server's address |
script version | script version | version | script version |
publication | part of a definition in a remote database, or part of a template in a reference database | none —all tables are synchronized | publication |
subscription | part of a definition in a remote database, or a part of a site in a reference database | none | none |
The synchronization definition is a version 7.0 database object describing data in an Adaptive Server Anywhere remote database that is to be synchronized with a particular MobiLink synchronization server. When using Adaptive Server Anywhere 9.0 or later, publications and synchronization subscriptions should be used instead.
For details, see Creating a remote database.
A synchronization definition should appear only in an Adaptive Server Anywhere 7.0 remote database. MobiLink consolidated servers are configured using scripts.
A synchronization definition specifies the following pieces of information
name The name of the synchronization definition, known only within the remote database.
site A name that uniquely identifies this particular MobiLink client.
type The type of stream to be used to communicate with the MobiLink synchronization server.
address The parameters necessary to connect to the MobiLink synchronization server.
script version The version of the synchronization scripts the MobiLink synchronization server is to use when synchronizing this client.
articles A description of the data to be synchronized. You can synchronize entire tables, or only particular rows and columns.
The following statement creates a synchronization definition named testpub that defines what data is to be synchronized with site demo_sync_site.
CREATE SYNCHRONIZATION DEFINITION testpub SITE 'demo_sync_site' TYPE 'tcpip' ADDRESS 'host=localhost;port=2439;' OPTION sv='version1' (table People( person_id, fname, lname ),table Pets);
In this statement,
The name of this synchronization definition is testpub. This name is only known within the remote database.
The name demo_sync_site uniquely identifies this client to the MobiLink synchronization server. This name should appear in the ml_user MobiLink system table, located in the consolidated database.
The synchronization is to occur over a TCP/IP connection. The connection parameters appear in a string in the ADDRESS clause.
The TCP/IP connection parameters show that the MobiLink synchronization server is listening on port 2439 of the current machine. Only the listed columns of the People table are synchronized. The option clause is included to indicate that the MobiLink synchronization server should use version1 of the synchronization scripts when processing data from this client. The default value of this parameter is default . Notice that the list of columns is also enclosed in parentheses.
The MobiLink synchronization server is to use the set of synchronization scripts identified by the name version1 when synchronizing this client. This script version name should appear in the ml_script_version MobiLink system table, located in the consolidated database.
All columns and rows of the Pets table and the listed columns of the People table are to be synchronized.
For the syntax of the MobiLink-synchronization-specific statements, see SQL Statements.
To synchronize a remote database with multiple MobiLink synchronization servers, create multiple synchronization definitions within the remote database. Each synchronization definition must have a unique site name because, from the point of view of the MobiLink synchronization server, each is a separate logical client.
Synchronizing the same data in one remote database with multiple MobiLink synchronization servers is not presently supported.
To use an Adaptive Server Anywhere 7 database as a MobiLink client, you use a synchronization definition to identify which data to upload. In version 8.0 and later, these are better rewritten as publications and synchronization subscriptions.
Suppose you wanted to synchronize the Customer and Sales_Order tables of the sample database. You could have created the following synchronization definition.
CREATE SYNCHRONIZATION DEFINITION testpub SITE 'demo_ml_user' TYPE 'tcpip' ADDRESS 'host=localhost;port=2439;' OPTION sv='version1' (TABLE Customer, TABLE Sales_Order);
Instead, you should now do the following.
First, publish the Customer and Sales_Order tables.
CREATE PUBLICATION testpub (TABLE Customer, TABLE Sales_Order);
Next, create a subscription to this publication for the MobiLink user. In this case, the MobiLink user is demo_ml_user. It is unnecessary that a database user of the same name to exist. MobiLink users and database users are independent.
CREATE SYNCHRONIZATION SUBSCRIPTION TO testpub FOR demo_ml_user TYPE 'tcpip' ADDRESS 'host=localhost;port=2439;' OPTION sv='version1'
The information is the same, but is broken into two smaller statements instead of one large one.
The SITE clause in the synchronization definition specifies that this particular MobiLink client will synchronizing using the MobiLink user id demo_sync_site. Synchronization is to occur over a TCP/IP connection. The synchronization server is to use the version1 version of the synchronization scripts when interacting with this client.
In the second case, the synchronized tables are published, and then a subscription is created for the demo_sync_site MobiLink user. The TYPE, ADDRESS, and OPTION clauses have the same syntax.