Working with scripts and users in SQL Central
You can view and modify existing scripts and write new ones in the
MobiLink Synchronization plug-in in SQL Central (formerly known as
Sybase Central). These procedures describe how to connect to the plug-in
and write scripts, and how to add a user to the consolidated
database.
To connect to a consolidated database in SQL Central:
-
Start SQL Central and select Connections>Connect with
MobiLink 11 from the menu bar. -
On the Identification page in the Connect to Consolidated
Database dialog box, select or browse to a data source name or file,
and click OK.
When you expand the node for a consolidated database in the
MobiLink Synchronization plug-in, you see folders with the following
labels: Tables, Connection Scripts, Synchronized Tables, Users,
Versions, and Notifications. All the procedures in this section begin by
opening one of these folders.
Script versions
Scripts are organized into groups called script versions. By
specifying a particular version, MobiLink clients can select which set
of synchronization scripts is used to process the upload stream and
prepare the download stream. If you want to define different versions
for scripts, you must add a script version to the consolidated database
before you add scripts for it.
If you create two different versions, make sure that you have
scripts for all required events in both versions.
To add a script version:
-
Open the Versions folder, then select File>New>Version
from the SQL Central menu bar. -
In the Create Script Version wizard, provide a name for the
version and optionally a description, then click Finish.SQL Central creates the new version and gives it a unique
integer identifier.
Adding synchronized tables and
scripts
Scripts added for connection events are executed for every
synchronization. Scripts added for table events are executed when a
specific table has been modified. You must specify that a table is
synchronized before you can add scripts for it.
To add a table for synchronization:
-
Open the Synchronized Tables folder and select
File>New>Synchronized Table. -
Specify a remote table name you want to synchronize or select
a table in the consolidated database that has the same name as a
table in the remote database. -
Click Finish.
To add a script to a synchronized table:
-
Double-click a table name in the Synchronized Tables folder,
then select File>New>Table Script. -
In the Create Table Script wizard, select the version for
which you want to add a script, select the event you want to cause
the script to execute, and click Next. -
Choose to create a new script definition and the language
(SQL, Java, or .NET) in which you want to write the definition, or
select an existing script version that you want to share for the new
script. -
Click Finish.
-
Type your script in the editor that displays, then save and
close the file.For example, if you want to remove rows that have been shipped
from the Order table in a remote database, you can place the
following SELECT statement in the download_delete_cursor event,
where order_id is the primary key column. The first parameter to
this event is the last_download timestamp. It is used here to supply
the value for a last_modified column:1234SELECT order_idFROM OrderWHERE status = 'Shipped'AND last_modified >= ?For more information about using the download_delete_cursor
event, see the section on “Writing download_delete_cursor scripts”
in the online MobiLink – Server Administration book.
To add a connection-level script:
-
Open the Connection Scripts folder and select
File>New>Connection Script from the menu bar. -
Follow steps 2 to 5 in the previous procedure.
Adding users
You can add users directly to the ml_user table in the
consolidated database, then provide the user names and optional
passwords to your users. To add a user, open the Users folder, select
File>New>User, and complete the Create User wizard.
You also have to add at least one user name to each remote
database, as described in Creating
MobiLink users.