[英]Need to delete N rows in SQL
I've tried this我试过这个
public void deleteRegisterByFileEx(String fileCode, int batchSize) {
String sql = "DELETE FROM TB_REGISTRO WHERE FILE_ID = ? LIMIT ?";
int[] argTypes = { Types.VARCHAR, Types.INTEGER };
List<Object[]> batchArgs = new ArrayList<>();
batchArgs.add(new Object[] { fileCode, batchSize });
template.batchUpdate(sql, batchArgs, argTypes);
}
and also this还有这个
String sql = "DELETE TOP (?) FROM TB_REGISTRO WHERE FILE_ID = ?";
int[] argTypes = { Types.INTEGER, Types.VARCHAR };
List<Object[]> batchArgs = new ArrayList<>();
batchArgs.add(new Object[] { batchSize, fileCode });
template.batchUpdate(sql, batchArgs, argTypes);
Neither of those worked, and i don't really know why, the only error message is ORA-00933: SQL command not properly ended这些都不起作用,我真的不知道为什么,唯一的错误消息是 ORA-00933: SQL 命令未正确结束
One approach would be like this:一种方法是这样的:
delete tb_registro
where rowid in
( select rowid from tb_registro
fetch first 3 rows only );
An order by
clause before fetch first
would make the result more predictable. fetch first
之前的order by
子句将使结果更可预测。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.