upload_fetch table event

Fetches rows from a synchronized table in the consolidated database for the purpose of row-level conflict detection.

Parameters

Parameter name for SQL scripts

Order

r.primary-key-1

1

r.primary-key-2

2

...

...

r.primary-key-N

N
Default action

None.

Remarks

The statement-based upload_fetch script fetches rows from a synchronized table for the purposes of conflict detection. It is a companion to the upload_update event.

The columns of the result set must match the number of columns being uploaded from the remote database for this table. If the values returned do not match the pre-image in the uploaded row, a conflict is identified.

Do not use READPAST table hints in upload_fetch scripts. If the script skips a locked row using READPAST, the synchronization logic thinks that the row was deleted. Depending on what scripts you have defined, this either causes the uploaded update to be ignored or it triggers conflict resolution. Ignoring the update is likely to be unacceptable behavior, and may be harmful. Triggering conflict resolution may not be a problem, depending on the resolution logic you have implemented.

You can have only one upload_fetch or upload_fetch_column_conflict script for each table in the remote database.

This script may be ignored if none of the following scripts are defined: upload_new_row_insert, upload_old_row_insert, and resolve_conflict.

See also
SQL example

The following SQL script is taken from the Contact sample and can be found in samples-dir\MobiLink\Contact\build_consol.sql. It is used to identify conflicts that occur when rows updated in the remote database Product table are uploaded. This script selects rows from a table also named Product, but depending on your consolidated and remote database schema, the two table names may not match.

CALL ml_add_table_script(
  'ver1',
  'Product',
  'upload_fetch',
  'SELECT id, name, size, quantity, unit_price
   FROM Product 
   WHERE id={ml r.id}' )
Java example

This script must return valid SQL.

The following call to a MobiLink system procedure registers a Java method called uploadFetchTable as the script for the upload_fetch table event when synchronizing the script version ver1.

CALL ml_add_java_table_script(
  'ver1',
  'Product',
  'upload_fetch',
  'ExamplePackage.ExampleClass.uploadFetchTable' )

The following is the sample Java method uploadFetchTable. It calls genUF to dynamically generate an UPLOAD statement.

public String uploadFetchTable() {
  return( genUF(_curTable) ); 
}
.NET example

This script must return valid SQL.

The following call to a MobiLink system procedure registers a .NET method called UploadFetchTable as the script for the upload_fetch table event when synchronizing the script version ver1.

CALL ml_add_dnet_table_script(
  'ver1',
  'Product',
  'upload_fetch',
  'TestScripts.Test.UploadFetchTable' )

The following is the sample .NET method UploadFetchTable. It calls GenUF to dynamically generate an UPLOAD statement.

public string UploadFetchTable() {
  return( GenUF(_curTable) ); 
}