我有 3 张桌子。表和。Test
_Folder
Iteration
每个test
都与一个Folder
. Folder
与 相关的是test
许多其他 的子folders
。
从这些folders
层次结构顶部的一个与表相关联Iteration
。
现在我想更新表中的Iteration_IDTest
。这样我就有了测试和迭代之间的“快速”连接。这是我的尝试:
update Test a set a.Iteration_ID =
(nvl((
--The Select Part
select b.ID from Iteration b inner join Folder c on b.Folder_ID = c.ID
where c.ID =
(
select * from
(
SELECT d.ID FROM Folder d START WITH d.ID = 135196 CONNECT BY PRIOR d.parent_id = d.id
order by LEVEL desc
)
where rownum= 1
)
--End Select Part
),0));
上面的查询有效,但我在 d.ID 有一个静态 ID。我想在那里设置a.Folder_ID :
update Test a set a.Iteration_ID =
(nvl((
--The Select Part
select b.ID from Iteration b inner join Folder c on b.Folder_ID = c.ID
where c.ID =
(
select * from
(
SELECT d.ID FROM Folder d START WITH d.ID = a.Folder_ID CONNECT BY PRIOR d.parent_id = d.id
order by LEVEL desc
)
where rownum= 1
)
--End Select Part
),0));
问题是 Oracle 不知道 a.folder_id
ORA-00904: "A"."FOLDER_ID": ungültiger Bezeichner
00904. 00000 - "%s: invalid identifier"
有人知道解决问题或改进查询的更好方法吗?
例如,使用select * from and rownum = 1
?
谢谢!