public java.sql.PreparedStatement getUpsertPreparedStatement( ) throws SQLException
Returns a java.sql.PreparedStatement instance which allows the user to add upsert (insert or update) operations to the download of a synchronization. The prepared statement applies to the DownloadTableData instance and contains a parameter for each column in the table.
To include an insert or update operation in the download, set all column values in your java.sql.PreparedStatement and then call the java.sql.PreparedStatement.executeUpdate method. Calling java.sql.PreparedStatement.executeUpdate on the prepared statement returns 0 if the insert or update operation was filtered and returns 1 if the operation was not filtered. An operation is filtered if it was uploaded in the same synchronization.
You must set all column values for download insert and update operations.
A java.sql.PreparedStatement instance for adding upsert operations to the download.
SQLException Thrown if there is a problem retrieving the upsert java.sql.PreparedStatement instance.
In the following example, the setDownloadInserts method uses the DownloadTableData.getUpsertPreparedStatement to obtain a prepared statement for rows you want to insert or update. The java.sql.PreparedStatement.setInt and PreparedStatement.setString methods set the column values, and the PreparedStatement.executeUpdate method sets the row values in the download.
void setDownloadInserts( DownloadTableData td ) { java.sql.PreparedStatement insert_ps = td.getUpsertPreparedStatement(); // This is the same as executing 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. } insert_ps.close(); } |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |