This lesson assumes you have completed all preceding lessons. See Lesson 1: Setting up your MobiLink consolidated database.
You can view, write, and modify synchronization scripts using Sybase Central. In this lesson, you write the following synchronization scripts:
upload_insert This event defines how new client-side data should be applied to the consolidated database.
download_cursor This event defines the data that should be downloaded to remote clients.
download_delete_cursor This event is required when using synchronization scripts that are not upload-only. You set the MobiLink server to ignore this event for the purpose of this tutorial.
Each script belongs to a designated script version. You must add a script version to the consolidated database before you add scripts.
Click View » Folders.
In the left pane of Sybase Central under MobiLink 12, expand mlreplay_project, Consolidated Databases, cons - DBA.
Right-click Versions and choose New » Version.
In the What Do You Want To Name The New Script Version field, type MLReplayDemo.
Click Finish.
In the left pane of Sybase Central under MobiLink 12, expand mlreplay_project, Consolidated Databases, cons - DBA.
Right-click Synchronized Tables and click New » Synchronized Table.
Click the Choose A Table In The Consolidated Database With The Same Name As The Remote Table option.
In the Which User Owns The Table You Want To Synchronize list, click DBA.
In the Which Table Do You Want To Synchronize list, click T1.
Click Finish.
The T1 table is registered as a synchronization table and you can add scripts to that table.
In the left pane of Sybase Central under MobiLink 12, expand mlreplay_project, Consolidated Databases, cons - DBA, Synchronized Tables.
Right-click T1 and click New » Table Script.
In the For Which Version Do You Want To Create The Table Script list, click MLReplayDemo.
In the Which Event Should Cause The Table Script To Be Executed list, click upload_insert and click Next.
Click Finish.
In the right pane of Sybase Central, use the following SQL script for the upload_insert event:
INSERT INTO T1 VALUES( cast({ml s.remote_id} as INTEGER), {ml r.2}, {ml r.3} ); |
The upload_insert event determines how data inserted into the remote database should be applied to the consolidated database. See upload_insert table event.
Click File » Save.
Repeat steps 13 to 16, specifying the download_cursor event instead of the upload_insert event in step 15.
In the right pane of Sybase Central, use the following SQL script for the download_cursor event:
SELECT pk1, pk2, c1 FROM T1; |
The download_cursor script defines a cursor to select consolidated database rows that are downloaded and inserted or updated in the remote database. For more information about download_cursor, see download_cursor table event.
Click File » Save.
Repeat steps 13 to 16, specifying the download_delete_cursor event instead of the upload_insert event in step 15.
In the right pane of Sybase Central, use the following SQL script for the download_delete_cursor event:
--{ml_ignore} |
Click File » Save.
Proceed to Lesson 4: Starting the MobiLink server to record.
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |