1 つのダウンロードテーブルの情報を同期用にカプセル化します。
public interface DownloadTableData
継承されたメンバーを含む DownloadTableData インタフェースのすべてのメンバー。
名前 | 説明 |
---|---|
ユーザが削除操作をダウンロードに追加できるようにする java.sql.PreparedStatement インスタンスを返します。 | |
このテーブルの最終ダウンロード時刻を返します。 | |
DownloadTableData インスタンスのメタデータを取得します。 | |
DownloadTableData インスタンスのテーブル名を返します。 | |
ユーザがアップサート (更新または挿入) 操作を同期のダウンロードに追加できるようにする java.sql.PreparedStatement インスタンスを返します。 |
このインタフェースを使用して、クライアントにダウンロードされるデータ操作を設定します。
DownloadData インタフェースを使用して、現在の同期の DownloadTableData インスタンスを取得できます。getUpsertPreparedStatement と getDeletePreparedStatement メソッドを使用して、それぞれ更新/挿入操作と削除操作を行う Java 準備文を取得できます。
テーブルをリモートでトランケートするため、すべてのプライマリキーを NULL に設定して削除文を実行できます。
java.sql.PreparedStatement.executeUpdate メソッドは、ダウンロードに使用する操作を登録します。java.sql.PreparedStatement の詳細については、Java Software Development Kit マニュアルを参照してください。
挿入と更新用の準備文のすべてのカラム値を設定してください。削除操作の場合は、プライマリキー値を設定します。削除とアップサート準備文を両方同時に開いておくことはできません。
ダイレクトローハンドリングの詳細については、ダイレクトローハンドリングを参照してください。
この例では、次の SQL 文を使用して作成された Mobile Link クライアントデータベースに remoteOrders というテーブルがあることを前提にしています。
CREATE TABLE remoteOrders ( pk INT NOT NULL, col1 VARCHAR(200), PRIMARY KEY (pk) ); |
次の例では DownloadData.getDownloadTableByName メソッドを使用して、remoteOrders テーブルを表す DownloadTableData インスタンスを返します。この例は、_cc という DBConnectionContext インスタンスがあることを前提としています。
// The method used for the handle_DownloadData event. public void handleDownload() throws SQLException { // Get the DownloadData for the current synchronization. DownloadData my_dd = _cc.getDownloadData(); // Get the DownloadTableData for the remoteOrders table. DownloadTableData td = my_dd.getDownloadTableByName("remoteOrders"); // User defined-methods to set download operations. setDownloadInserts(td); setDownloadDeletes(td); // ... } |
この例では、SetDownloadInserts メソッドは GetUpsertCommand を使用して、挿入または更新するローのコマンドを取得します。IDbCommand は、リモートデータベースに挿入する値の設定先となるパラメータを保持します。
void setDownloadInserts(DownloadTableData td) { java.sql.PreparedStatement insert_ps = td.getUpsertPreparedStatement(); // The following method calls are the same as the following SQL statement: // INSERT INTO remoteOrders(pk, col1) values(2300, "truck"); insert_ps.setInt(1, 2300); insert_ps.setString(2, "truck"); int update_result = insert_ps.executeUpdate(); if (update_result == 0) { // Insert was filtered because it was uploaded // in the same synchronization. } else { // Insert was not filtered. } } |
setDownloadDeletes メソッドは、DownloadTableData.getDeletePreparedStatement を使用して、削除したいローの準備文を取得します。java.sql.PreparedStatement.setInt メソッドは、リモートデータベースの削除したいローのプライマリキーの値を設定し、java.sql.PreparedStatement.executeUpdate メソッドは、ダウンロードに使用するローの値を登録します。
void setDownloadDeletes(DownloadTableData td) { java.sql.PreparedStatement delete_ps = td.getDeletePreparedStatement(); // The following method calls are the same as the following SQL statement: // DELETE FROM remoteOrders where pk=2300; delete_ps.setInt(1, 2300); delete_ps.executeUpdate(); } |
getDeletePreparedStatement メソッド
getLastDownloadTime メソッド
getMetaData メソッド
getName メソッド
getUpsertPreparedStatement メソッド
![]() |
DocCommentXchange で意見交換できます
|
Copyright © 2013, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0 |