Background... As part of existing data conversion we need to convert to populate Adhoc Hierarchies with a limited information.
Currently we have a finger countable members from CXO House treated to be users of this Adhoc Hierarchies. They have their choice of Employee Hierarchical combinations for a purpose.
These hierarchies have only Parent - Child relation and can be of at any level to any level of Org Hierarchy. In the other words... child never become a parent unless he has subordinates for him.
We have an employee table of ORG EmpHierarchy (OH) that has Organizational hierarchies.
But, which can't be directly used but we can take help of these columns to form our logic. This table is no way related to current model.
We have a few other tables HeadofDepartment(HOD), HierarchyDetails(HD) and a Stage Table same as HD.
OrgEmpHierarchy (OH) Has:
OH_ID - Organizational HierarchyID (DB Sequence)
OH_PID - (Parent ID) one of the values from previous column.
OH_EmpID - Organizational EmpID.
HeadofDepartment (HOD) Has:
HOD_ID - Head of Dept. ID (DB Sequence)
HOD_EmpID - Organizational EmpID.
HierarchyDetails (HD) Has:
HD_ID - Hierarchy Details ID (DB Sequence)
HD_PID - (ParentID) of of the values from previous column.
HD_HOD_ID - (Foreign Key) HOD_ID from HOD.
HD_EmpID - Organizational EmpID.
We need to populate the Hierarchy for each HOD_ID from Head of Department (HOD) in Hierarchy Details (HD) table. We are able to populate values in HD for HD_ID, HD_HOD_ID, HD_Emp_ID. HD_PID is populated with NULL.
Now with the help of OH, HOD I need to populate Hierarchies in HD_PID in HD table.
Can some one give me a Oracle SQL/ PLSQL query which udpates the HD_PID?