что не так с моим следующим утверждением:
UPDATE TableToUpdate SET ColumnToUpdate = (
SELECT ColumnWithNewValues
FROM (
SELECT ColumnWithNewValues, ROWNUM AS N
FROM Table1 t1, Table2 t2 -- join tables
WHERE t2.Schluessel = t1.Schluessel -- join condition
AND t1.DateFrom <= TableToUpdate.Date -- <==== Error, reference to TableToUpdate
AND t1.DatumTo >= TableToUpdate.Date
-- ... some other conditions, not important here ...
) tmp
WHERE tmp.N = 5 -- Use the fifth row to update the row of TableToUpdate
)
При выполнении этого я получу ошибку от оракула:
ORA-00904: "TableToUpdate"."Date": Ungültiger Bezeichner
По-английски, я думаю, это будет означать:
ORA-00904: "TableToUpdate"."Date": Invalid identifier
Итак, кажется, что я не могу ссылаться на TableToUpdate из коррелированного подзапроса в операторе SELECT. В MSSQL это работает при замене ROWNUM, специфичного для оракула, на эквивалентную технологию, конечно.
Кто-нибудь может мне помочь?