The following pseudocode illustrates how upload events and upload scripts are invoked.
These events take place at the upload location in the complete event model. See Overview of MobiLink events.
------------------------------------------------------ upload ------------------------------------------------------ begin_upload // Connection event for each table being synchronized { begin_upload // Table event } handle_UploadData for each table being synchronized { begin_upload_rows for each uploaded INSERT or UPDATE for this table { if( INSERT ) { <upload_inserted_row> } if( UPDATE ) { <upload_updated_row> } } end_upload_rows } for each table being synchronized IN REVERSE ORDER { begin_upload_deletes for each uploaded DELETE for this table { <upload_deleted_row> } end_upload_deletes } For each table being synchronized { if( begin_upload table script is called ) { end_upload // Table event } } if( begin_upload connection script was called ) { end_upload // Connection event for each table being synchronized { upload_statistics // Table event. } upload_statistics // Connection event. COMMIT |
------------------------------------------------------ <upload_inserted_row> ------------------------------------------------------ // NOTES: // - Only table scripts for the current table are involved. ConflictsAreExpected <- ( upload_new_row_insert script is defined or upload_old_row_insert script is defined or resolve_conflict script is defined ) if( upload_insert script is defined ) { upload_insert } else if( ConflictsAreExpected and upload_update script is not defined and upload_insert script is not defined and upload_delete script is not defined ) { // Forced conflict. upload_new_row_insert resolve_conflict } else { // Ignore the insert. } |
------------------------------------------------------ upload_updated_row ------------------------------------------------------ // NOTES: // - Only table scripts for the current table are involved. // - Both the old (original) and new rows are uploaded for // each update. ConflictsAreExpected <- ( upload_new_row_insert script is defined or upload_old_row_insert script is defined or resolve_conflict script is defined ) Conflicted <- FALSE if( upload_update script is defined ) { if( ConflictsAreExpected and upload_fetch script is defined ) { FETCH using upload_fetch INTO current_row if( current_row <> old row ) { Conflicted <- TRUE } } if( not Conflicted ) { upload_update } } else if( upload_update script is not defined and upload_insert script is not defined and upload_delete script is not defined ) { // Forced conflict. Conflicted <- TRUE } if( ConflictsAreExpected and Conflicted ) { upload_old_row_insert upload_new_row_insert resolve_conflict } |
------------------------------------------------------ upload_deleted_row ------------------------------------------------------ // NOTES: // - Only table scripts for the current table are involved. ConflictsAreExpected <- ( upload_new_row_insert script is defined or upload_old_row_insert script is defined or resolve_conflict script is defined ) if( upload_delete is defined ) { upload_delete } else if( ConflictsAreExpected and upload_update script is not defined and upload_insert script is not defined and upload_delete script is not defined ) { // Forced conflict. upload_old_row_insert resolve_conflict } else { // Ignore this delete. } |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |