MobiLink Synchronization Reference
Synchronization Events
Overview of MobiLink events
The following pseudo-code provides an overview of the sequence in which download events, and hence the script of the same name, are invoked.
These events take place at the download location in the complete event model provided in Overview of MobiLink events.
------------------------------------------------------ prepare_for_download ------------------------------------------------------ prepare_for_download modify_last_download_timestamp if( prepare_for_download script is defined or modify_last_download_timestamp script is defined ) { COMMIT }
------------------------------------------------------ download ------------------------------------------------------ begin_download for each table being synchronized { begin_download_deletes for each row in download_delete_cursor { if( all primary key columns are NULL ) { send TRUNCATE to remote } else { send DELETE to remote } } end_download_deletes begin_download_rows for each row in download_cursor { send INSERT ON EXISTING UPDATE to remote } end_download_rows } modify_next_download_timestamp end_download COMMIT
If an acknowledgement is expected, and if no confirmation of the downloads is received from the client, the entire download transaction is rolled back in the consolidated database.
For more information, see SendDownloadACK (sa) extended option for Adaptive Server Anywhere remotes or Send Download Acknowledgement synchronization parameter for UltraLite remotes.
The download stream does not distinguish between inserts and updates. The script associated with the download_cursor event is a SELECT statement that defines the rows to be downloaded. The client detects whether the row exists or not and carries out the appropriate insert or update operation.
At the end of the download processing, the client automatically deletes rows that violate referential integrity.
For more information, see Referential integrity and synchronization.