我对合并有疑问。当它在SqlDeveloper中运行时,它可以正确执行。但是,当我尝试使用jdbc在Java中执行时,它冻结了。
@Override
public void updateRegion(int id, int region) {
try {
PreparedStatement statement = connection.prepareStatement(
"MERGE INTO LINKING_DOCTORS_TO_REGION l "
+ "USING LINKING_DOCTORS_TO_REGION l1 "
+ "ON (l1.user_ = ?) "
+ "WHEN MATCHED THEN UPDATE SET region = ? "
+ "WHEN NOT MATCHED THEN INSERT (region, user_) VALUES (?, ?)");
statement.setInt(1, id);
statement.setInt(4, id);
statement.setInt(2, region);
statement.setInt(3, region);
statement.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
怎么了?谢谢
我在sqldeveloper中进行了一些更改,但是我忘记了提交。