Tuesday, 4 June 2019

Query to get user manager and department details in Oracle Cloud

SELECT DISTINCT
    pu.username,
    pea.email_address employee_email,
    ppnf.first_name
    || ' '
    || ppnf.last_name employee_name,
    hauft.name department,
    (
        SELECT
            ppnf1.full_name
        FROM
            per_assignment_supervisors_f pasf,
            per_person_names_f ppnf1
        WHERE
            1 = 1
            AND   pasf.manager_type = 'LINE_MANAGER'
            AND   pasf.manager_id = ppnf1.person_id
            AND   SYSDATE BETWEEN ppnf1.effective_start_date AND ppnf1.effective_end_date
            AND   SYSDATE BETWEEN pasf.effective_start_date AND pasf.effective_end_date
            AND   ppnf1.name_type = 'GLOBAL'
            AND   pasf.person_id = pu.person_id
            AND   ROWNUM = 1
    ) supervisorname,
    pea1.email_address supervisor_email
FROM
    ase_user_b u,
    per_users pu,
    per_all_people_f papf,
    per_person_names_f ppnf,
    per_email_addresses pea,
    hr_org_unit_classifications_f houcf,
    hr_all_organization_units_f haouf,
    hr_organization_units_f_tl hauft,
    per_all_assignments_m paam,
    per_assignment_supervisors_f pasf,
    per_email_addresses pea1
WHERE
    u.user_guid = pu.user_guid
    AND   nvl(u.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(u.effective_end_date,SYSDATE) >= SYSDATE
    AND   nvl(pu.active_flag,'Y') = 'Y'
    AND   nvl(pu.suspended,'N') = 'N'
    AND   pu.person_id = papf.person_id
    AND   nvl(papf.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(papf.effective_end_date,SYSDATE) >= SYSDATE
    AND   papf.person_id = ppnf.person_id
    AND   nvl(ppnf.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(ppnf.effective_end_date,SYSDATE) >= SYSDATE
    AND   papf.person_id = pea.person_id
    AND   papf.primary_email_id = pea.email_address_id
    AND   papf.person_id = paam.person_id
    AND   haouf.organization_id = houcf.organization_id
    AND   haouf.organization_id = hauft.organization_id
    AND   nvl(haouf.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(haouf.effective_end_date,SYSDATE) >= SYSDATE
    AND   hauft.language = 'US'
    AND   hauft.effective_start_date = haouf.effective_start_date
    AND   hauft.effective_end_date = haouf.effective_end_date
    AND   houcf.classification_code = 'DEPARTMENT'
    AND   nvl(hauft.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(hauft.effective_end_date,SYSDATE) >= SYSDATE
    AND   hauft.organization_id = paam.organization_id
    AND   paam.primary_assignment_flag = 'Y'
    AND   paam.assignment_type IN (
        'E',
        'C'
    )
    AND   paam.effective_latest_change = 'Y'
    AND   nvl(paam.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(paam.effective_end_date,SYSDATE) >= SYSDATE
    AND   papf.person_id = pasf.person_id
    AND   pasf.manager_type = 'LINE_MANAGER'
    AND   nvl(pasf.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(pasf.effective_end_date,SYSDATE) >= SYSDATE
    /*AND   pasf.manager_id=ppnf1.person_id
    AND   ppnf1.name_type = 'GLOBAL'
    AND   nvl(ppnf1.effective_start_date,SYSDATE) <= SYSDATE
    AND   nvl(ppnf1.effective_end_date,SYSDATE) >= SYSDATE*/
    AND   pasf.manager_id = pea1.person_id
   --AND upper(pu.username) like 'AALAM%'

Thanks
Amar Alam

1 comments:

Unknown said...

Emblix Academy – Digital marketing institute in KPHB, we address all major and minor aspects required for any student’s advancement in digital marketing. Clutch USA named our Digital Marketing Institute the best SEO firm.

The future of digital marketing is promising and full of possibilities.

As a result, skilled digital marketers who can keep up with the rising demand are in high order.
In the Emblix Academy Digital marketing institute in KPHB, you will learn about all the major and minor modules of digital marketing, from Search engine marketing to Social Media Marketing and almost all Tools used for Digital Marketing.
One stop place for all Digital Marketing courses! Emblix Academy is a Team of dedicated Professionals with 12years of experience in various Digital Platforms. We assure to provide the best Digital Marketing courses to enhance your Career.
Certifications

• Search Advertising
• Display Advertising
• Analytics Certification
• Hubspot Certification
• Bing Certification
• Twitter Certification
• Facebook Certification

https://emblixacademy.com/

Post a Comment