When the MobiLink server detects a conflict using an upload_fetch script, the following events take place.
The MobiLink server inserts old row values uploaded from the remote database as defined by the upload_old_row_insert script. Typically, the old values are inserted into a temporary table.
The MobiLink server inserts the new row values uploaded from the remote database as defined by the upload_new_row_insert script. Typically, the new values are inserted into a temporary table.
The MobiLink server executes the resolve_conflict script. In this script you can either call a stored procedure, or define a sequence of steps to resolve the conflict using the new and old row values.
For more information, see resolve_conflict table event.
In the following example, you create scripts for six events and then you create a stored procedure.
In the begin_synchronization script, you create two temporary tables called contact_new and contact_old. (You could also do this in the begin_connection script.)
The upload_fetch script detects the conflict.
When there is a conflict, the upload_old_row_insert and upload_new_row_insert scripts populate the two temporary tables with the new and old data uploaded from the remote database.
The resolve_conflict script calls the stored procedure MLResolveContactConflict to resolve the conflict.
The stored procedure MLResolveContactConflict is as follows:
CREATE PROCEDURE MLResolveContactConflict( ) BEGIN --update the consolidated database only if the new contact date --is later than the existing contact date UPDATE contact c SET c.contact_date = cn.contact_date FROM #contact_new cn WHERE c.id = cn.id AND cn.contact_date > c.contact_date; --cleanup DELETE FROM #contact_new; DELETE FROM #contact_old; END
|Envoyer votre avis sur cette page par email.||Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|