473,394 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

get all hierarchy data

salesmr
I have created a query using the connect by prior syntax to get a list of all employees and their hierarchy, but am trying to store this information in a table starting with the employee and storing their management information all the way up to our president.

For example,
Employee ID -> Direct Supervisor ID -> Manager ID -> Senior Manager ID -> Director ID -> VP ID -> Pres ID

for each employee. Obviously some will have more levels than other employees, but need to have this dynamic.

Currently, I have this query, but cannot figure out how to get data from hierarchy to table format as discussed above:

SELECT lpad(' ', (level - 1) * 4) || emp_name, level
from hr_employees
where emp_status = 'Active'
CONNECT BY manager_id = prior emp_id
START WITH emp_id = '123456'

Please help....thanks, Michelle
Sep 23 '07 #1
2 2389
amitpatel66
2,367 Expert 2GB
I have created a query using the connect by prior syntax to get a list of all employees and their hierarchy, but am trying to store this information in a table starting with the employee and storing their management information all the way up to our president.

For example,
Employee ID -> Direct Supervisor ID -> Manager ID -> Senior Manager ID -> Director ID -> VP ID -> Pres ID

for each employee. Obviously some will have more levels than other employees, but need to have this dynamic.

Currently, I have this query, but cannot figure out how to get data from hierarchy to table format as discussed above:

SELECT lpad(' ', (level - 1) * 4) || emp_name, level
from hr_employees
where emp_status = 'Active'
CONNECT BY manager_id = prior emp_id
START WITH emp_id = '123456'

Please help....thanks, Michelle
If you want to insert the data returned by the above select query you can use the following logic to insert into another table:

Expand|Select|Wrap|Line Numbers
  1.  
  2. INSERT INTO tab1 (SELECT lpad(' ', (level - 1) * 4) || emp_name, level
  3. from hr_employees 
  4. where emp_status = 'Active' 
  5. CONNECT BY manager_id = prior emp_id
  6. START WITH emp_id = '123456')
  7.  
Make sure the table tab1 have 2 columns to insert the data returned by SELECT query
Sep 24 '07 #2
Maybe I wasn't clear in what I was asking. Ultimately I want something similar to the "sys_connect_by_path" (so that I can see ALL of the parents to a child), but I have 8 rather than 9i so it is not an option for me to use this function. I'm trying to reproduce the output though. Is this something that you can help with?

Thanks, Michelle
Sep 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
1
by: Chris Lasher | last post by:
Hello, I'm trying to write a tool to scrape through some of the Ribosomal Database Project II's (http://rdp.cme.msu.edu/) pages, specifically, through the Hierarchy Browser....
2
by: Darryll Petrancuri | last post by:
Greetings! I could really use some suggestions on how to improve on the following, it at all possible: Table 'Customer' --------------------- ID GUID PK ....
1
by: Rolf Kemper | last post by:
Dear All, may be some one has a good idea for the follwoing problem. In the xml data below you see a kind of abstract netlist as we use it for chip design. Where the H tag stands for a logical...
0
by: archway | last post by:
Hi, I would like to build a hierarchy of ProductNode objects like so ProductNode ---Product Node ---ProductNode ------ProductNode ------ProductNode ---ProductNode
1
by: Gustaf Liljegren | last post by:
My input data consists of a list of parent-child relationships. One item in this list can be modelled like this: +---------+ | Item | +---------+ | Parent | | Child | +---------+
2
by: Do | last post by:
Hi, I have a database table with the following fields: id, name, parentid. These fields are supposed to create a hierarchy for a list box, an infinite hierarchy Child fields of parent fields...
1
by: veracon | last post by:
I'd like to know how to make the following string: food fruit red cherry yellow banana meat pork foo
8
by: Bostonasian | last post by:
I don't even know where to begin this as hierarchy is always confusing to construct dynamically in any form(query, xslt,etc). However it is very easy to follow when it's presented. I've done...
10
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.