Вы находитесь на странице: 1из 3

SELECT

PAPF.PERSON_NUMBER,
PPNF_EMP.FIRST_NAME||' '||PPNF_EMP.LAST_NAME EMPLOYEE_NAME,
PEA.EMAIL_ADDRESS,
TO_CHAR(PPOS.DATE_START,'DD/MM/YYYY') JOINING_DATE,
LOC.LOCATION_NAME LOCATION_NAME,
HAOUFV.NAME DEPARTMENT_NAME,
HAP.NAME POSITION,
PGF.NAME GRADE,
PASF.MANAGER_TYPE,
PPNF_MGR.FIRST_NAME||' '||PPNF_MGR.LAST_NAME MANAGER_NAME,
PAAM.ASSIGNMENT_NUMBER,
PPG.SEGMENT1 DIRECTORATE,
PPG.SEGMENT4 DIVISION,
PAAM.ASS_ATTRIBUTE11 "GD/HOD",
PPG.SEGMENT2 COMPANY,
PPG.SEGMENT5 EMPLOYEE_GROUP,
PPTV.USER_PERSON_TYPE PERSON_TYPE,
HCV.COMPETENCY COMPETENCY_NAME,
HCV.DESCRIPTION COMPETENCY_DESCRIPTION,
TO_CHAR(HPI.DATE_FROM,'YYYY') YEAR

FROM
PER_ALL_PEOPLE_F PAPF
,PER_PERSON_NAMES_F PPNF_EMP
,PER_PERSON_NAMES_F PPNF_MGR
,PER_ALL_PEOPLE_F PAPF_MGR
,PER_ALL_ASSIGNMENTS_M PAAM
,PER_PEOPLE_GROUPS PPG
,HR_LOCATIONS_ALL LOC
,PER_PERIODS_OF_SERVICE PPOS
,PER_EMAIL_ADDRESSES PEA
,PER_GRADES PGF
,PER_JOBS HAP
,PER_PERSON_TYPES_VL PPTV
,HR_ALL_ORGANIZATION_UNITS_F_VL HAOUFV
,PER_ASSIGNMENT_SUPERVISORS_F PASF
,HRT_COMPETENCIES_V HCV
,HRT_PROFILES_B HPB
,HRT_PROFILE_ITEMS HPI
,HRT_CONTENT_TYPES_VL HCTV

WHERE
PAPF.PERSON_ID = PAAM.PERSON_ID
AND PAPF.PERSON_ID=PPNF_EMP.PERSON_ID
AND PAPF_MGR.PERSON_ID=PPNF_MGR.PERSON_ID
AND PAAM.PEOPLE_GROUP_ID=PPG.PEOPLE_GROUP_ID(+)
AND PAAM.LOCATION_ID=LOC.LOCATION_ID(+)
AND LOC.ACTIVE_STATUS(+) = 'A'
AND PAAM.ASSIGNMENT_TYPE = 'E'
AND PAAM.PRIMARY_ASSIGNMENT_FLAG = 'Y'
AND PAAM.PRIMARY_WORK_RELATION_FLAG='Y'
AND PAAM.EFFECTIVE_LATEST_CHANGE = 'Y'
AND PAAM.PERIOD_OF_SERVICE_ID = PPOS.PERIOD_OF_SERVICE_ID
AND PPOS.PERSON_ID = PAPF.PERSON_ID
AND PAAM.ORGANIZATION_ID = HAOUFV.ORGANIZATION_ID(+)
AND PAPF.PRIMARY_EMAIL_ID = PEA.EMAIL_ADDRESS_ID (+)
AND PGF.GRADE_ID(+)= PAAM.GRADE_ID
AND PAAM.JOB_ID=HAP.JOB_ID(+)
AND PAAM.PERSON_TYPE_ID =PPTV.PERSON_TYPE_ID
AND PAAM.ASSIGNMENT_ID = PASF.ASSIGNMENT_ID
AND PAPF_MGR.PERSON_ID = PASF.MANAGER_ID
AND PASF.MANAGER_TYPE = 'LINE_MANAGER'
AND HPB.PERSON_ID = PAPF.PERSON_ID
AND HPB.PROFILE_ID = HPI.PROFILE_ID
AND HCV.CONTENT_ITEM_ID(+) = HPI.CONTENT_ITEM_ID
AND HCTV.CONTENT_TYPE_NAME = 'Competencies'
AND HCTV.CONTENT_TYPE_ID(+) = HPI.CONTENT_TYPE_ID
AND PPNF_EMP.NAME_TYPE='GLOBAL'
AND PPNF_MGR.NAME_TYPE='GLOBAL'
AND SYSDATE BETWEEN PAPF.EFFECTIVE_START_DATE AND PAPF.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN PPNF_EMP.EFFECTIVE_START_DATE AND
PPNF_EMP.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN PPNF_MGR.EFFECTIVE_START_DATE AND PPNF_MGR.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN PAPF_MGR.EFFECTIVE_START_DATE AND
PAPF_MGR.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN PASF.EFFECTIVE_START_DATE AND PASF.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN PAAM.EFFECTIVE_START_DATE AND PAAM.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN HAOUFV.EFFECTIVE_START_DATE AND HAOUFV.EFFECTIVE_END_DATE
AND ((SYSDATE BETWEEN PEA.DATE_FROM AND PEA.DATE_TO ) OR (PEA.DATE_TO IS NULL))
AND SYSDATE BETWEEN PGF.EFFECTIVE_START_DATE(+) AND PGF.EFFECTIVE_END_DATE(+)
AND SYSDATE BETWEEN HAP.EFFECTIVE_START_DATE(+) AND HAP.EFFECTIVE_END_DATE(+)
AND (COALESCE(:P_YEAR,NULL) IS NULL OR TO_CHAR(HPI.DATE_FROM,'YYYY') IN
(:P_YEAR))
AND (COALESCE(:P_LOCATION,NULL) IS NULL OR LOC.LOCATION_NAME IN (:P_LOCATION))
AND (COALESCE(:P_DIRECTORATE,NULL) IS NULL OR PPG.SEGMENT1 IN (:P_DIRECTORATE))
AND (COALESCE(:P_MANAGER,NULL) IS NULL OR (PPNF_MGR.FIRST_NAME||' '||
PPNF_MGR.LAST_NAME||' - '||PAPF_MGR.person_number) IN (:P_MANAGER))
AND (COALESCE(:P_ASG_STATUS,NULL) IS NULL OR PAAM.ASSIGNMENT_STATUS_TYPE IN
(:P_ASG_STATUS))
AND (COALESCE(:P_DIVISION,NULL) IS NULL OR PPG.SEGMENT4 IN (:P_DIVISION))
AND (COALESCE(:P_DEPARTMENT,NULL) IS NULL OR HAOUFV.NAME IN (:P_DEPARTMENT))
AND ( HPI.DATE_FROM BETWEEN NVL(:FROM_DATE,NULL) AND NVL(:TO_DATE, SYSDATE)
OR
(:FROM_DATE IS NULL AND :TO_DATE IS NULL )
)
order by papf.person_number
=========================
Parameter-Department
select distinct name from HR_ALL_ORGANIZATION_UNITS_F_VL where sysdate between
effective_start_date and effective_end_date order by name
---------------
Parameter-Line Manager
select distinct (PPNF.FIRST_NAME||' '||PPNF.LAST_NAME||' - '||papf.person_number)
fULL_NAME from per_all_people_f papf, per_assignment_supervisors_f
pasf,per_person_names_f ppnf
where pasf.manager_id = papf.person_id
and papf.person_id =ppnf.person_id
and pasf.manager_type = 'LINE_MANAGER'
and pasf.primary_flag = 'Y'
---------
Parameter-Location
SELECT DISTINCT LOCATION_NAME FROM HR_LOCATIONS_ALL WHERE ACTIVE_STATUS = 'A' order
by LOCATION_NAME
--------
Parameter-Assignment Status
SELECT DISTINCT PER_SYSTEM_STATUS FROM PER_ASSIGNMENT_STATUS_TYPES_VL
ORDER BY fULL_NAME

Оценить