Tracks synchronization statistics for download 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 as specified in your SYNCHRONIZATION USER definition. |
1 |
s.warnings |
INTEGER. The number of warnings issued. |
2 |
s.errors |
INTEGER. The number of errors, including handled errors, that occurred. |
3 |
s.fetched_rows |
INTEGER. The number of rows fetched by the download_cursor script. |
4 |
s.deleted_rows |
INTEGER. The number of rows fetched by the download_delete_cursor script. |
5 |
s.filtered_rows |
INTEGER. The number of rows from the deleted_rows parameter actually sent to the remote. This reflects download filtering of uploaded values. |
6 |
s.bytes |
INTEGER. The number of bytes sent to the remote as the download. |
7 |
None.
The download_statistics event allows you to gather, for any user, statistics on downloads. The download_statistics connection script is called just prior to the commit at the end of the download transaction.
Depending on the command line, not all warnings or errors are logged, so the warnings and errors counts may be more than the number of warnings or errors logged.
The following example inserts synchronization statistics into a table called download_audit.
CALL ml_add_connection_script( 'ver1', 'download_statistics', 'INSERT INTO download_audit( user_name, warnings, errors, deleted_rows, fetched_rows, download_rows, bytes ) VALUES ( {ml s.username}, {ml s.warnings}, {ml s.errors}, {ml s.fetched_rows}, {ml s.deleted_rows}, {ml s.filtered_rows}, {ml s.bytes})') |
Once vital 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 downloadStatisticsConnection as the script for the download_statistics event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'download_statistics', 'ExamplePackage.ExampleClass.downloadStatisticsConnection' ) |
Following is the sample Java method downloadStatisticsConnection. It prints the number of fetched rows to the MobiLink output log. (Note that printing the number of fetched rows to the MobiLink output log might be useful at development time but would slow down a production server.)
public String downloadStatisticsConnection( String user, int warnings, int errors, int fetchedRows, int deletedRows, int bytes ) { java.lang.System.out.println( "download connection stats fetchedRows: " + fetchedRows ); return ( null ); } |
The following call to a MobiLink system procedure registers a .NET method called DownloadStats as the script for the download_statistics connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'download_statistics', 'TestScripts.Test.DownloadStats' ) |
Following is the sample .NET method DownloadStats. It prints the number of fetched rows to the MobiLink output log. (Note that printing the number of fetched rows to the MobiLink output log might be useful at development time but would slow down a production server.)
public string DownloadStats( string user, int warnings, int errors, int deletedRows, int fetchedRows, int downloadRows, int bytes ) { System.Console.WriteLine( "download connection stats fetchedRows: " + fetchedRows ); return ( null ); } |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |