Contents Index download_cursor cursor event download_statistics connection event

MobiLink Synchronization Reference
  Synchronization Events

download_delete_cursor cursor event


Function 

Defines a cursor to select rows that are to be deleted in the remote database.

Parameters 

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.

Event parameters are optional only if no subsequent parameters are specified. You must use parameter 1 if you want to use parameter 2.

Item Parameter Description
1 last_download TIMESTAMP
2 ml_username VARCHAR(128)
Default action 

None.

Description 

The MobiLink synchronization server opens a read-only cursor with which to fetch a list of rows to download, and then insert or update in the remote database. This script must contain a SELECT statement that returns the primary key values of the rows to be deleted from the table in the remote database.

The parameters are the last_download timestamp and the user name. You can use these values by placing a question mark in your SQL statement.

You can have one download_delete_cursor script for each table in the remote database.

If the download_delete_cursor has NULLs for the primary key columns for one or more rows in a table, then MobiLink tells the remote to delete all the data in the table. For a complete description of this behavior, see Deleting all the rows in a table.

The last_download timestamp is the value obtained from the consolidated database during the last successful synchronization immediately prior to the download phase. If the current user has never synchronized successfully, this value is set to 1900-01-01.

Note that rows deleted from the consolidated database will not appear in a result set defined by a download_delete_cursor event, and so are not automatically deleted from the remote database. One technique for identifying rows to be deleted from remote databases is to add a column to the consolidated database table identifying a row as inactive.

For Java and .NET applications, this script must return valid SQL.

See also 

download_cursor cursor event

SQL example 

This example is taken from the Contact sample and can be found in Samples\MobiLink\Contact\build_consol.sql. It deletes from the remote database any customers that:

Java example 

The following stored procedure call registers a Java method called downloadDeleteCursor as the script for the download_delete_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',
   'download_delete_cursor',
   'ExamplePackage.ExampleClass.downloadDeleteCursor' )

Following is the sample Java method downloadDeleteCursor. It calls a Java method that generates the SQL for the download delete cursor.

public String downloadDeleteCursor( Timestamp ts,
String user )
{  return( getDownloadCursor( _curUser, _curTable ) ); }
.NET example 

The following stored procedure call registers a .NET method called DownloadDeleteCursor as the script for the download_delete_cursor cursor event when synchronizing the script version ver1 and the table table1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_dnet_table_script(
  'ver1',
  'table1',
  'download_delete_cursor',
  'TestScripts.Test.DownloadDeleteCursor'
)

Following is the C# signature for the call DownloadDeleteCursor.

public string DownloadDeleteCursor(
  DateTime timestamp,
  string user )

Contents Index download_cursor cursor event download_statistics connection event