MobiLink Synchronization Reference
Synchronization Events
Defines the cursor that the MobiLink synchronization server uses to insert the old values of rows that were updated in the remote database, but that conflict with values presently in the consolidated database. The event is also used to insert the values of deleted rows when in forced conflict mode.
Use statement-based events for uploadsThis script has been deprecated. Use the statement-based event upload_old_row_insert instead. Support for the old_row_cursor event is likely to be removed from future releases. |
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.
Item | Parameter | Description |
---|---|---|
1 | ml_username | VARCHAR(128) |
None.
When a row is updated on a remote database, the MobiLink client saves a copy of the original values. The client sends both old and new values to the MobiLink synchronization server.
When the MobiLink synchronization server receives an updated row, it compares the original values with the present values in the consolidated database, using the upload_cursor cursor event. If the old uploaded values do not match the current values in the consolidated database, the row conflicts. Instead of updating the row, the MobiLink synchronization server inserts both old and new values into the consolidated database using the old_row_cursor event and the new_row_cursor event.
It is common practice to use temporary tables to store the old and new versions of conflicting rows. In Adaptive Server Anywhere, you can create these tables in an earlier script. Some non-ASA consolidated databases support temporary tables, but they usually differ significantly from the temporary tables offered by ASA. Consult your DBMS documentation for details. An alternative to a temporary table is a base table with an extra column for the MobiLink user name. This effectively partitions the rows of the base table between concurrent synchronizations.
The MobiLink synchronization server uses a cursor to insert the old uploaded values from conflicting rows into the consolidated database. This script contains the SELECT statement used to define this cursor.
You can have one old_row_cursor script for each table in the remote database.
Normally, the columns in the SELECT list must match those in the client table in both order and type. However, the MobiLink synchronization server permits you to add one extra column. If you do so, the MobiLink synchronization server automatically inserts the user name into the first column, then proceeds to insert the old row values using the remaining columns, as usual.
upload_old_row_insert table event
The following SELECT statement defines an old_row_cursor script suited to the CustDB sample application for an Oracle installation. The primary key of the ULOrder table is order_id.
SELECT order_id, cust_id, prod_id, emp_id, disc, quant, notes, status FROM ULOldOrder
The following SELECT statement could instead be used for the same client table. This variation includes the permitted one extra row. The MobiLink synchronization server automatically stores the user name in the first column.
SELECT user_name, order_id, cust_id, prod_id, emp_id, disc, quant, notes, status FROM ULOldOrder
This script must return valid SQL.
The following stored procedure call registers a Java method called oldRowCursor as the script for the old_row_cursor event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.
call ml_add_java_table_script( 'ver1', 'table1', 'old_row_cursor', 'ExamplePackage.ExampleClass.oldRowCursor' )
Following is the sample Java method oldRowCursor. It dynamically generates an old row cursor statement by calling a Java method.
public String oldRowCursor() { return( getRowCursor( _curTable ) ); }