How do I create a batch update that won't update a column if the passed-in parameter value is null? For example:
String UPDATE_STMT = "UPDATE MY_TABLE SET col1 = ?, col2 = ?, col3 = ?";
Connection conn = getConnection();
PreparedStatement pstmt = conn.preparedStatement(UPDATE_STMT);
List items = getItems();
for (ItemType item : items) {
stmt.setString(1, item.x);
stmt.setString(2, item.y);
stmt.setString(3, item.z);
}
pstmt.executeBatch();
How do I code it so that col1 will only be updated with the value of item.x if item.x is not null or empty? if item.x is null/empty, I don't want the current value in the col1 field to be overridden. This is for an Oracle 10g database.