我在java中有以下准备好的语句:
with main_select as
(select request_id,rownum iden
from
(select request_id
from queue_requests
where request_status = 0 and
date_requested <= sysdate and
mod(request_id,?) = ?
order by request_priority desc, oper_id, date_requested)
where rownum < ?)
select *
from queue_requests qr, main_select ms
where qr.request_id in ms.request_id
order by ms.iden for update skip locked;
它不会执行:
ORA-02014:无法从DISTINCT,GROUP BY等视图中选择FOR UPDATE
我将尝试解释为什么我需要所有的select语句:
所以,我想从queue_requests中选择数据,保留前x行,保留select的顺序并锁定行。
有办法吗?
答案 0 :(得分:0)
问题似乎是,您想要对main_select的结果设置锁定。我猜,你可以在with子句中选择select for update
,如:
with main_select as
(select request_id,rownum iden
from (subselect)
where rownum < ?
for update skip locked)
但正如我所说的那样幸运。