0
的作品我有這樣的SQL爲H2數據庫:更換TOP 1,它與Oracle
update EVENT event
set event.SENT_INTO_WF_BY_ID = (
select TOP 1 eventRev.USER_ID
from EVENT_REV eventRev
where eventRev.EVENT_ID = event.EVENT_ID
and eventRev.STATUS != (
select TOP 1 eventRev2.STATUS
from EVENT_REV eventRev2
where VALID_FROM is not null
and eventRev.EVENT_ID = eventRev2.EVENT_ID
order by VALID_FROM asc
)
order by eventRev.VALID_TO asc nulls last
)
where event.SENT_INTO_WF_BY_ID is null
,我來翻譯它,使之成爲甲骨文工作。 Oracle中的「TOP」不存在,所以我嘗試這樣的:
update EVENT event
set event.SENT_INTO_WF_BY_ID = (
select eventRev.USER_ID
from (select eventRev.USER_ID from EVENT_REV eventRev
where eventRev.EVENT_ID = event.EVENT_ID
order by eventRev.VALID_TO asc nulls last)
where rownum = 1
)
where event.SENT_INTO_WF_BY_ID is null;
但是,這給我的錯誤:
Error: ORA-00904: "event"."EVENT_ID": invalid identifier
有甚至沒有更多的嵌套選擇的解決方案?
工程就像一個迷人的!謝謝。 – GarfieldKlon