ITPub博客

首页 > IT职业 > IT生活 > 分析函数学习2 SYS_CONNECT_BY_PATH

分析函数学习2 SYS_CONNECT_BY_PATH

原创 IT生活 作者:abcbbc 时间:2007-05-05 16:19:38 0 删除 编辑

SYS_CONNECT_BY_PATH is valid only in hierarchical queries. It returns the path of a column value from root to node, with column values separated by char for each row returned by CONNECT BY condition.
Both column and char can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The string returned is of VARCHAR2 datatype and is in the same character set as column.

[@more@]


The following example returns the path of employee names from employee Kochhar to all employees of Kochhar (and their employees):

SELECT LPAD(' ', 2*level-1)||SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
START WITH last_name = 'Kochhar'
CONNECT BY PRIOR employee_id = manager_id;
Path
---------------------------------------------------------------
/Kochhar
/Kochhar/Greenberg
/Kochhar/Greenberg/Faviet
/Kochhar/Greenberg/Chen
/Kochhar/Greenberg/Sciarra
/Kochhar/Greenberg/Urman
/Kochhar/Greenberg/Popp
/Kochhar/Whalen
/Kochhar/Marvis
/Kochhar/Baer
/Kochhar/Higgens
/Kochhar/Higgens/Gietz
12 rows selected.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/219138/viewspace-913419/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-09-07

  • 博文量
    56
  • 访问量
    699642