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
2 2389
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: -
-
INSERT INTO tab1 (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')
-
Make sure the table tab1 have 2 columns to insert the data returned by SELECT query
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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(...
|
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....
|
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
....
|
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...
|
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
|
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 |
+---------+
|
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...
|
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
|
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...
|
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....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
| |