The CONNECT_BY_ROOT unary operator is for use only in hierarchical queries (SQLSTATE 428H4). For every row in the hierarchy, this operator returns the expression for the row's root ancestor.
The result type of the operator is the result type of the expression.
Rules:
Notes:
CONNECT_BY_ROOT FIRSTNME || LASTNAME
returns
the FIRSTNME value of the root ancestor row concatenated with the
LASTNAME value of the actual row in the hierarchy, because this expression
is equivalent to: (CONNECT_BY_ROOT FIRSTNME) || LASTNAME
rather
than: CONNECT_BY_ROOT (FIRSTNME || LASTNAME)
Example:
SELECT CONNECT_BY_ROOT DEPTNAME AS ROOT, DEPTNAME
FROM DEPARTMENT START WITH DEPTNO IN ('B01','C01','D01','E01')
CONNECT BY PRIOR DEPTNO = ADMRDEPT
This query
returns:ROOT DEPTNAME
------------------ -----------------------
PLANNING PLANNING
INFORMATION CENTER INFORMATION CENTER
DEVELOPMENT CENTER DEVELOPMENT CENTER
DEVELOPMENT CENTER MANUFACTURING SYSTEMS
DEVELOPMENT CENTER ADMINISTRATION SYSTEMS
SUPPORT SERVICES SUPPORT SERVICES
SUPPORT SERVICES OPERATIONS
SUPPORT SERVICES SOFTWARE SUPPORT
SUPPORT SERVICES BRANCH OFFICE F2
SUPPORT SERVICES BRANCH OFFICE G2
SUPPORT SERVICES BRANCH OFFICE H2
SUPPORT SERVICES BRANCH OFFICE I2
SUPPORT SERVICES BRANCH OFFICE J2