[英]Unable to do a executeBatch() on Netezza - JDBC
Im getting an error when i try to do an executeBatch() on netezza. 我在netezza上执行executeBatch()时收到错误消息。 Following is the error:
以下是错误:
org.netezza.error.NzSQLException: ERROR: Update canceled: attempt to update a target row with values from multiple join rows.. org.netezza.error.NzSQLException:错误:更新已取消:尝试使用多个联接行中的值更新目标行。
Please take a look at the following code: 请看下面的代码:
String updateDim = "UPDATE DIM_DETAILS set c1 = ? where rep_id = 185 and ar_id = ? and pe_id = ? and se_id = ? and by_id = ?";
stmt3 = conn.prepareStatement(updateDim);
for (Dim dim : updatedDimList ){
upcount += 1;
opvalue = BeanUtils.getProperty(dim, dimName.toLowerCase());
stmt3.setString(1, opvalue);
stmt3.setString(2, dim.getAr_id());
stmt3.setString(3, dim.getPe_id());
stmt3.setString(4, dim.getSe_id());
stmt3.setString(5, dim.getBy_id());
stmt3.addBatch();
//stmt3.executeUpdate();
//System.out.println("Successfully Updated Rows: "+upcount);
}
int[] recordsAffected = stmt3.executeBatch();
conn.commit();
seems like you are trying to update multiple rows multiple times as there might be duplicate rows. 似乎您正在尝试多次更新多行,因为可能存在重复的行。 Please try to remove such duplicates.
请尝试删除此类重复项。
Set<String> keys = new HashSet<String>();
//inside the loop
if(keys.contains(dim.getAr_id() + "#" + dim.getPe_id() + "#" + dim.getCe_id()))
continue;
else
keys.add(dim.getAr_id() + "#" + dim.getPe_id() + "#" + dim.getCe_id());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.