Oracle Magazine, Jan/Feb 2018
Database Developer and DBA ETL ORACLE MAGAZINE JANUARY FEBRUARY 2018 90 7902 FORD 7566 7369 SMITH 7902 7698 BLAKE 7839 7499 ALLEN 7698 7521 WARD 7698 7654 MARTIN 7698 7844 TURNER 7698 7900 JAMES 7698 7782 CLARK 7839 7934 MILLER 7782 An easy way to demonstrate the traversal of the hierarchy is to use the pseudocolumn called LEVEL which returns the depth within the hierarchy of the row that is currently being traversed Combining LEVEL with RPAD to provide a simple indentation Listing 2 demonstrates how you can more clearly visualize the depth of the hierarchy starting with KING and navigating down to employees at the deepest level of the hierarchy such as ADAMS WARD MARTIN TURNER and JAMES The hierarchy is often described as analogous to a tree structure with the deepest levels of the hierarchy being leaf elements and the other levels that is those that sit logically above the leaves being branches Code Listing 2 Demonstrating the hierarchy depth with RPAD SQL select empno rpad level 3 ename ename mgr 2 from emp 3 connect by prior empno mgr 4 start with mgr is null
You must have JavaScript enabled to view digital editions.