Conflict resolution scripts for statement-based uploads commonly require access to the old and new values of rows uploaded from the remote database. This data script event allows you to handle the old values of rows uploaded from 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. |
N/A |
s.username |
VARCHAR(128). The MobiLink user name. This parameter is optional. |
Optional (1 if referenced) |
r. pk-column-1 |
Required. The first primary key column value from the old (pre-image) row, referenced by column name or column number. |
1 (2 if username is referenced) |
... | ... | ... |
r. pk-column-N |
Required. The last primary key column value from the old (pre-image) row, referenced by column name or column number. |
N (N+1 if username is referenced) |
r. column-1 |
Required. The first non-primary key column value from the old (pre-image) row, referenced by column name or column number. |
N + 1 (N+2 if username is referenced) |
... | ... | ... |
r. column-M |
Required. The last non- primary key column value from the old (pre-image) row, referenced by column name or column number. |
N + M (N+M+1 if username is referenced) |
None.
When a MobiLink client sends an updated row to the MobiLink server, it includes not only the new values (the post-image), but also a copy of the old row values (the pre-image). When the pre-image does not match the current values in the consolidated database, a conflict is detected.
After MobiLink detects a conflict, this event allows you to save pre-image values to a table. You can use this event to assist in developing conflict resolution procedures. The parameters for this event hold old row values from the remote database before the update is performed on the corresponding consolidated database table. This event is also used to insert rows in forced-conflict mode (forced-conflict mode has been deprecated).
Conflict detection is usually much faster when done all at once in the upload_update script. See upload_update table event.
The script for this event is usually an insert statement that inserts the old row into a temporary table for use by a resolve_conflict script.
You can have one upload_old_row_insert script for each table in the remote database.
This script must be implemented in SQL. For Java or .NET processing of rows, see Direct row handling.
This example handles updates made on the product table in the remote database. The script inserts the old value of the row into a global temporary table named product_conflict. The final column of the table identifies the row as an old row.
CALL ml_add_table_script( 'ver1', 'table1', 'upload_old_row_insert', 'INSERT INTO DBA.product_conflict ( id, name, size, quantity, unit_price, row_type ) VALUES ( {ml r.id}, {ml r.name}, {ml r.size}, {ml r.quantity}, {ml r.unit_price}, ''Old'' )' ) |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |