Tracks synchronization statistics for upload operations.
In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.
In SQL scripts, you can specify event parameters by name or with a question mark, but 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 want 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 |
---|---|---|
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. |
1 |
s.warnings |
INTEGER. The number of warnings that occurred. |
2 |
s.errors |
INTEGER. The number of errors that occurred. |
3 |
s.inserted_rows |
INTEGER. The number of rows that were successfully inserted in the consolidated database. |
4 |
s.deleted_rows |
INTEGER. The number of rows that were successfully deleted from the consolidated database. |
5 |
s.updated_rows |
INTEGER. The number of rows that were successfully updated in the consolidated database. |
6 |
s.conflicted_inserts |
INTEGER. Always zero. |
7 |
s.conflicted_deletes |
INTEGER. Always zero. |
8 |
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. |
9 |
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 no upload_new_row_insert script in forced conflict 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. |
10 |
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. |
11 |
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. |
12 |
s.bytes |
INTEGER. The amount of memory used within the MobiLink server to store the upload. |
13 |
s.deadlocks |
INTEGER. The number of deadlocks in the consolidated database that were detected for the synchronization. |
14 |
None.
The upload_statistics event allows you to gather, for any user, statistics on uploads. The upload_statistics connection script is called just prior to the commit at the end of the upload transaction.
The following example inserts synchronization statistics for upload operations into the table upload_summary_audit.
CALL ml_add_connection_script ( 'ver1', 'upload_statistics', 'INSERT INTO upload_summary_audit ( ml_user, warnings, errors, inserted_rows, deleted_rows, updated_rows, conflicted_inserts, conflicted_deletes, conflicted_updates, bytes, ignored_inserts, ignored deletes, ignored_updates, bytes, deadlocks ) VALUES ( {ml s.username}, {ml s.warnings}, {ml s.errors}, {ml s.inserted_rows}, {ml s.deleted_rows}, {ml s.updated_rows}, {ml s.conflicted_inserts}, {ml s.conflicted_deletes}, {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.
The following call to a MobiLink system procedure registers a Java method called uploadStatisticsConnection as the script for the upload_statistics connection event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'upload_statistics', 'ExamplePackage.ExampleClass.uploadStatisticsConnection' ) |
The following is the sample Java method uploadStatisticsConnection. It logs some statistics to the MobiLink message log. (Note that logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)
public String uploadStatisticsConnection( String user, 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 ); return ( null ); } |
The following call to a MobiLink system procedure registers a .NET method called UploadStats as the script for the upload_statistics connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'upload_statistics', 'TestScripts.Test.UploadStats' ) |
The following is the sample .NET method UploadStats. It logs some statistics to the MobiLink message log. (Note that logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)
public string UploadStats ( string user, 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 ); return ( null ); } |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |