oracle - oracle:如何在分页中选择更新?
问题描述
在分页的情况下锁定查询的有限结果:
select * from Employee order by id asc
作为
select * from (select a.*, ROWNUM rnum from
(select * from Employee order by id asc) a
where ROWNUM <= 10) where rnum >= 6 for update
错误:
ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
如何在分页中选择更新行?
解决方案
在这种情况下,您必须将 ROWID 与 FOR UPDATE 子句一起使用。
尝试:
select * from
Employee
where rowid in
(
select r from
(select rowid r from
Employee
order by id asc
) a
where rownum <= 10
) for update;
推荐阅读
- debian - geoip 模块在 debian 中无法正常工作
- java - 用 ArrayList 填充 TableView(列和数据)
- python - PSO 可以收敛于非零导数的点吗?
- python - 使用烧瓶 wtforms 中的 SubmitField 与 html 提交按钮有什么优点/缺点?
- javascript - 如何摆脱来自 Firebase 的此错误消息?
- python - (Python) 将文件值转换为 dict
- python - 如何在json中配置日志文件获取错误:ValueError:无法配置根记录器
- html - 如何使 backgroundImage 在框内完全显示
- java - 如何从 Visual Studio 代码中的其他文件调用 Java 类
- ios - 增加最后一节和新标题之间的高度