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

download_statistics table event

Provides access to synchronization statistics for download operations by 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.username

VARCHAR(128). The MobiLink user name as specified in your SYNCHRONIZATION USER definition.

1

s.table

VARCHAR(128). The table name.

2

s.warnings

INTEGER. The number of warnings issued.

3

s.errors

INTEGER. The number of errors, including handled errors, that occurred.

4

s.fetched_rows

INTEGER. The number of rows fetched by the download_cursor script.

5

s.deleted_rows

INTEGER. The number of rows fetched by the download_delete_cursor script.

6

s.filtered_rows

INTEGER. The number of rows filtered from the fetched_rows. This reflects download filtering of uploaded values.

7

s.bytes

INTEGER. The number of bytes sent to the remote database as the download.

8

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
Default action

None.

Remarks

The download_statistics event allows you to gather, for any user and table, statistics on downloads as they apply to that table. The download_statistics table script is called just before the commit at the end of the download 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 synchronization statistics into a table called download_audit. Once vital statistics are inserted into the audit table, you may use these statistics to monitor your synchronizations and make optimizations where applicable.

CALL ml_add_table_script(
 'ver1',
 'table1',
 'download_statistics',
 'INSERT INTO download_audit (
   user_name, 
   table, warnings, 
   errors,
   fetched_rows,
   deleted_rows,  
   filtered_rows, 
   bytes)
  VALUES (
   {ml s.username}, 
   {ml s.table}, 
   {ml s.warnings}, 
   {ml s.errors}, 
   {ml s.fetched_rows}, 
   {ml s.deleted_rows}, 
   {ml s.filtered_rows}, 
   {ml s.bytes})')
Java example

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

CALL ml_add_java_table_script(
  'ver1',
  'table1',
  'download_statistics',
  'ExamplePackage.ExampleClass.downloadStatisticsTable' )

The following is the sample Java method downloadStatisticsTable. It prints some statistics for this table to the MobiLink message log. (Printing statistics for a table 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 downloadStatisticsTable(
  String user,
  String table,
  int warnings,
  int errors,
  int fetchedRows,
  int deletedRows,
  int filteredRows,
  int bytes ) {
  java.lang.System.out.println( "download table stats "
   + "table: " + table + "bytes: " + bytes );
  }}
.NET example

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

CALL ml_add_dnet_table_script(
 'ver1',
 'table1',
 'download_statistics',
 'TestScripts.Test.DownloadTableStats'
)

The following is the sample .NET method DownloadTableStats. It prints some statistics for this table to the MobiLink message log. (Printing statistics for a table 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 DownloadTableStats(
  string user,
  string table,
  int warnings,
  int errors,
  int fetchedRows,
  int deletedRows,
  int filteredRows,
  int bytes ) {
  System.Console.WriteLine( "download table stats "
   + "table: " + table + "bytes: " + bytes );
  }}}