开发者

how i do this in oracle pl/sql

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜