|
|

楼主 |
发表于 2005/8/19 08:08:04
|
显示全部楼层
得到公司组织架构的SQL:
create or replace view cux_org_level1 as
select a_pa.organization_id as org_id1, a_pa.name as org_name1, a_ch.organization_id as org_id2, a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent = 0
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
create view cux_org_level2 as
select a_pa.organization_id as org_id1, a_pa.name as org_name1, a_ch.organization_id as org_id2, a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0)
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
create view cux_org_level3 as
select a_pa.organization_id as org_id1,
a_pa.name as org_name1,
a_ch.organization_id as org_id2,
a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0))
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
create view cux_org_level4 as
select a_pa.organization_id as org_id1,
a_pa.name as org_name1,
a_ch.organization_id as org_id2,
a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0)))
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
select t.organization_id_parent, t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0);
select t1.org_name2,
t2.org_name2,
t3.org_name2,
t4.org_name2
from cux_org_level1 t1,
cux_org_level2 t2,
cux_org_level3 t3,
cux_org_level4 t4
where t1.org_id2 = t2.org_id1(+)
and t2.org_id2 = t3.org_id1(+)
and t3.org_id2 = t4.org_id1(+)
;
[upload=txt]viewFile.asp?ID=223[/upload]
[此贴子已经被作者于2005-8-19 8:09:15编辑过]
|
-
-
hO0s0BGD.txt
3.32 KB, 下载次数: 219, 下载积分: 努力值 -5 点
ERP系统常用SQL集锦
|