Processes statements related to a specific table just before uploading inserts and updates from the specified table in the remote database.
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. Using question marks has been deprecated and it is recommended that you use named parameters. 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 (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. |
1 |
s.table |
VARCHAR(128). The table name. |
2 |
None.
This event occurs immediately before applying the changes that result from inserts and deletes to the remote table named in the second parameter.
You can have one begin_upload_rows script for each table in the remote database. The script is only invoked when the table is actually synchronized.
The begin_upload_rows table event is used to perform whatever steps you need performed before uploading inserts and updates for a particular table. The following script calls a stored procedure that prepares the consolidated database for inserts and updates into the Inventory table:
CALL ml_add_table_script( 'MyCorp 1.0', 'Inventory', 'begin_upload_rows', 'CALL PrepareForUpserts()' ) |
The following call to a MobiLink system procedure registers a Java method called beginUploadRows as the script for the begin_upload_rows table event when synchronizing the script version ver1.
CALL ml_add_java_table_script( 'ver1', 'table1', 'begin_upload_rows', 'ExamplePackage.ExampleClass.beginUploadRows' ) |
The following is the sample Java method beginUploadRows. It prints a message to the MobiLink message log. (Note that printing a message 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 String beginUploadRows( String user, String table ) throws java.sql.SQLException { java.lang.System.out.println( "Starting upload rows for table: " + table + " and user: " + user ); return ( null ); }} |
The following call to a MobiLink system procedure registers a .NET method called BeginUploadRows as the script for the begin_upload_rows table event when synchronizing the script version ver1 and the table table1.
CALL ml_add_dnet_table_script( 'ver1', 'table1', 'begin_upload_rows', 'TestScripts.Test.BeginUploadRows' ) |
The following is the sample .NET method BeginUploadRows. It prints a message to the MobiLink message log. (Note that printing a message 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 string BeginUploadRows( string user, string table ) { System.Console.WriteLine( "Starting upload rows for table: " + table + " and user: " + user ); return ( null ); }}} |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |