Contents Index Overview of MobiLink events Events during download

MobiLink Synchronization Reference
  Synchronization Events
    Overview of MobiLink events

Events during upload


The following pseudo-code illustrates how upload events and upload scripts are invoked.

These events take place at the upload location in the complete event model. For more information, see Overview of MobiLink events.

------------------------------------------------------
upload
------------------------------------------------------

begin_upload
  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
  }
  end_upload
  upload_statistics
  COMMIT
------------------------------------------------------
<upload_inserted_row>
------------------------------------------------------
// NOTES:
// - Only table scripts for the current table are involved.
// - Cursor-based upload scripts, like upload_cursor,
//   are deprecated, and so are not shown.

UploadUsingStatements <- (
       upload_insert script is defined
    or upload_update script is defined
    or upload_delete script is defined
    or upload_fetch script is defined
    or upload_new_row_insert script is defined
    or upload_old_row_insert script is defined )
if( UploadUsingStatements ) {
  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
  }
} 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.
// - Cursor-based upload scripts, like upload_cursor,
//   are deprecated, and so are not shown.
UploadUsingStatements <- (
       upload_insert script is defined
    or upload_update script is defined
    or upload_delete script is defined
    or upload_fetch script is defined
    or upload_new_row_insert script is defined
    or upload_old_row_insert script is defined )
if( UploadUsingStatements ) {
  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
  }
} else {
  // ignore the update
}
------------------------------------------------------
upload_deleted_row
------------------------------------------------------
// NOTES:
// - Only table scripts for the current table are involved.
// - Cursor-based upload scripts, like upload_cursor,
//   are deprecated, and so are not shown.

UploadUsingStatements <- (
       upload_insert script is defined
    or upload_update script is defined
    or upload_delete script is defined
    or upload_fetch script is defined
    or upload_new_row_insert script is defined
    or upload_old_row_insert script is defined )
if( UploadUsingStatements ) {
  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
  }
} else {
    // ignore this delete
}

Contents Index Overview of MobiLink events Events during download