Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

upload_statistics table event

Provides access to synchronization statistics for upload operations for a specific table.

Parameters

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, use the appropriate corresponding data type.

In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you are going to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts Description Order (deprecated for SQL)
s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable
s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable

s.username

VARCHAR(128). The MobiLink user name.

1

s.table

VARCHAR(128). The table name.

2

s.warnings

INTEGER. The number of warnings issued in the upload of the table.

3

s.errors

INTEGER. The number of errors, including handled errors, that occurred in the upload of the table.

4

s.inserted_rows

INTEGER. The number of rows that were successfully inserted in the consolidated database.

5

s.deleted_rows

INTEGER. The number of rows that were successfully deleted from the consolidated database.

6

s.updated_rows

INTEGER. The number of rows that were successfully updated in the consolidated database.

7

s.conflicted_updates

INTEGER. The number of update rows that caused conflict. A row is included only when a resolve conflict script was successfully called for it.

10

s.ignored_inserts

INTEGER. The total number of upload insert rows that were ignored. They were ignored because 1) there is no upload_insert script in normal mode; or 2) errors occurred when the MobiLink server was invoking the corresponding script and the handle_error or handle_odbc_error event returned 1000.

11

s.ignored_deletes

INTEGER. The number of upload delete rows that caused errors while the upload_delete script was invoked, when the handle_error or handle_odbc_error are defined and returned 1000, or when there is no upload_delete script defined for the given table.

12

s.ignored_updates

INTEGER. The number of upload update rows that caused conflict but a resolve conflict script was not successfully called or no upload_update script was defined.

13

s.bytes

INTEGER. The amount of memory used within the MobiLink server to store the upload.

14

s.deadlocks

INTEGER. The number of deadlocks in the consolidated database that were detected for the synchronization.

15

Default action

None.

Remarks

The upload_statistics event allows you to gather, for any user, vital statistics on synchronization happenings as they apply to any table. The upload_statistics table script is called just before the commit at the end of the upload transaction.

Note Depending on the command line, not all warnings are logged. The warnings count passed to this script is the number of warnings that would be logged when no warnings are disabled, which may be more than the number of warnings logged.
SQL Example

The following example inserts a row into a table used to track upload statistics.

CALL ml_add_connection_script(
 'ver1',
 'upload_statistics',
 'INSERT INTO my_upload_statistics ( 
   user_name, 
   table_name, 
   num_warnings, 
   num_errors, 
   inserted_rows, 
   deleted_rows, 
   updated_rows,
   conflicted_updates, 
   ignored_inserts,
   ignored_deletes, 
   ignored_updates, bytes,
   deadlocks )
  VALUES( 
   {ml s.username}, 
   {ml s.table}, 
   {ml s.warnings}, 
   {ml s.errors}, 
   {ml s.inserted_rows}, 
   {ml s.deleted_rows}, 
   {ml s.updated_rows}, 
   {ml s.conflicted_updates}, 
   {ml s.ignored_inserts}, 
   {ml s.ignored_deletes}, 
   {ml s.ignored_updates}, 
   {ml s.bytes}, 
   {ml s.deadlocks} )'  )

The following example works with an Oracle consolidated database.

CALL ml_add_connection_script(
 'ver1',
 'upload_statistics',
 'INSERT INTO upload_tables_audit (
  id,
  user_name,
  table,
  warnings,
  errors,
  inserted_rows,
  deleted_rows,
  updated_rows,
  conflicted_updates,
  ignored_inserts,
  ignored_deletes,
  ignored_updates, 
  bytes, 
  deadlocks )
 VALUES ( 
   ut_audit.nextval,
   {ml s.username}, 
   {ml s.table}, 
   {ml s.warnings}, 
   {ml s.errors}, 
   {ml s.inserted_rows}, 
   {ml s.deleted_rows}, 
   {ml s.updated_rows}, 
   {ml s.conflicted_updates}, 
   {ml s.ignored_inserts}, 
   {ml s.ignored_deletes}, 
   {ml s.ignored_updates}, 
   {ml s.bytes}, 
   {ml s.deadlocks} )' )

Once statistics are inserted into the audit table, you may use these statistics to monitor your synchronizations and make optimizations where applicable.

Java example

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

CALL ml_add_java_table_script(
  'ver1',
  'table1',
  'upload_statistics',
  'ExamplePackage.ExampleClass.uploadStatisticsTable' )

The following is the sample Java method uploadStatisticsTable. It logs some statistics to the MobiLink message log. Logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

package ExamplePackage; 
public class ExampleClass {
  String _curUser = null;
public void uploadStatisticsTable(
  String user,
  String table,
  int warnings,
  int errors,
  int insertedRows,
  int deletedRows,
  int updatedRows,
  int conflictedInserts,
  int conflictedDeletes,
  int conflictedUpdates,
  int ignoredInserts,
  int ignoredDeletes,
  int ignoredUpdates,
  int bytes,
  int deadlocks ) {
  java.lang.System.out.println( "updated rows: " +
    updatedRows ); 
  }
.NET example

The following call to a MobiLink system procedure registers a .NET method called UploadTableStats as the script for the upload_statistics table event when synchronizing the script version ver1 and the table table1.

CALL ml_add_dnet_table_script(
  'ver1',
  'table1',
  'upload_statistics',
  'TestScripts.Test.UploadTableStats'
)

The following is the sample .NET method uploadStatisticsTable. It logs some statistics to the MobiLink message log. (Logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

namespace TestScripts {
public class Test {
  string _curUser = null;
public void UploadTableStats(
  string user,
  string table,
  int warnings,
  int errors,
  int insertedRows,
  int deletedRows,
  int updatedRows,
  int conflictInserts,
  int conflictDeletes,
  int conflictUpdates,
  int ignoredInserts,
  int ignoredDeletes,
  int ignoredUpdates,
  int bytes,
  int deadlocks ) {
  System.Console.WriteLine( "updated rows: " +
    updatedRows );
  }}}