开发者

how i do this in oracle pl/sql

开发者 https://www.devze.com 2023-04-01 08:50 出处:网络
I have the follow table: example: nodes: id_nodeid_parent -------------------- 13 32 2-1 I want to insert in other table the level of descent. For example:

I have the follow table: example: nodes:

id_node   id_parent
--------------------
1         3
3         2
2         -1

I want to insert in other table the level of descent. For example:

ancestor:

id_node  id_parent  level
-------------------------
1       开发者_C百科 3          1
3        2          1
1        2          2


Should be something like this:

SELECT id_node, id_parent, level
FROM nodes
START WITH id_parent = -1
CONNECT BY PRIOR id_node = id_parent
0

精彩评论

暂无评论...
验证码 换一张
取 消