The below query can be useful when you are
working in Oracle Projects and you need to find out the Project Manager
Name and Email Address for a particular project.
/* Formatted on 6/6/2014 4:32:17 PM (QP5 v5.115.810.9015) */
SELECT pe.full_name, pe.email_address
FROM pa_project_parties ppp,
pa_projects_all ppa,
pa_project_role_types pprt,
per_all_people_f pe,
pa_project_assignments pa,
fnd_user u,
(SELECT pj.name job_name,
haou.organization_id org_id,
haou.name org_name,
paf.person_id,
paf.assignment_type
FROM per_all_assignments_f paf,
per_jobs pj,
hr_all_organization_units haou
WHERE TRUNC (SYSDATE) BETWEEN TRUNC (paf.effective_start_date)
AND TRUNC (paf.effective_end_date)
AND paf.primary_flag = 'Y'
AND paf.organization_id = haou.organization_id
AND NVL (paf.job_id, -99) = pj.job_id(+)) prd
WHERE ppa.project_id = :p_project_id
AND DECODE (pa.assignment_id, NULL, pprt.meaning, pa.assignment_name) =
'Project Manager'
AND ppp.project_id = ppa.project_id
AND ppp.project_role_id = pprt.project_role_id
AND ppp.resource_source_id = pe.person_id
AND TRUNC (SYSDATE) BETWEEN TRUNC (ppp.start_date_active)
AND NVL (TRUNC (ppp.end_date_active), SYSDATE)
AND pe.effective_start_date =
(SELECT MIN (papf.effective_start_date)
FROM per_all_people_f papf
WHERE papf.person_id = pe.person_id
AND papf.effective_end_date >= TRUNC (SYSDATE))
AND pe.effective_end_date >= TRUNC (SYSDATE)
AND ppp.project_party_id = pa.project_party_id(+)
AND NVL (prd.assignment_type, '-99') IN
('C',
DECODE (DECODE (pe.current_employee_flag,
'Y', 'Y',
DECODE (pe.current_npw_flag, 'Y', 'Y', 'N')),
'Y',
'E',
'B'
),
'E',
'-99')
AND ppp.resource_source_id = prd.person_id(+)
AND u.employee_id(+) = ppp.resource_source_id
AND ppp.object_type = 'PA_PROJECTS'
AND ppp.object_id = ppa.project_id;
SELECT pe.full_name, pe.email_address
FROM pa_project_parties ppp,
pa_projects_all ppa,
pa_project_role_types pprt,
per_all_people_f pe,
pa_project_assignments pa,
fnd_user u,
(SELECT pj.name job_name,
haou.organization_id org_id,
haou.name org_name,
paf.person_id,
paf.assignment_type
FROM per_all_assignments_f paf,
per_jobs pj,
hr_all_organization_units haou
WHERE TRUNC (SYSDATE) BETWEEN TRUNC (paf.effective_start_date)
AND TRUNC (paf.effective_end_date)
AND paf.primary_flag = 'Y'
AND paf.organization_id = haou.organization_id
AND NVL (paf.job_id, -99) = pj.job_id(+)) prd
WHERE ppa.project_id = :p_project_id
AND DECODE (pa.assignment_id, NULL, pprt.meaning, pa.assignment_name) =
'Project Manager'
AND ppp.project_id = ppa.project_id
AND ppp.project_role_id = pprt.project_role_id
AND ppp.resource_source_id = pe.person_id
AND TRUNC (SYSDATE) BETWEEN TRUNC (ppp.start_date_active)
AND NVL (TRUNC (ppp.end_date_active), SYSDATE)
AND pe.effective_start_date =
(SELECT MIN (papf.effective_start_date)
FROM per_all_people_f papf
WHERE papf.person_id = pe.person_id
AND papf.effective_end_date >= TRUNC (SYSDATE))
AND pe.effective_end_date >= TRUNC (SYSDATE)
AND ppp.project_party_id = pa.project_party_id(+)
AND NVL (prd.assignment_type, '-99') IN
('C',
DECODE (DECODE (pe.current_employee_flag,
'Y', 'Y',
DECODE (pe.current_npw_flag, 'Y', 'Y', 'N')),
'Y',
'E',
'B'
),
'E',
'-99')
AND ppp.resource_source_id = prd.person_id(+)
AND u.employee_id(+) = ppp.resource_source_id
AND ppp.object_type = 'PA_PROJECTS'
AND ppp.object_id = ppa.project_id;
thank you
ReplyDelete