[Home] [Help]
341:
342: -- JH New EHRI Phones
343: CURSOR cur_phones IS
344: SELECT pho.phone_number, pho.phone_type
345: FROM per_phones pho
346: WHERE pho.parent_table = 'PER_ALL_PEOPLE_F'
347: AND pho.parent_id = g_person_id
348: AND pho.phone_type IN ('W1','H1','M');
349:
352: SELECT contact.last_name, contact.first_name, contact.middle_names, contact.suffix
353: ,pho.phone_number, rel.date_start
354: FROM per_contact_relationships_v2 rel
355: ,per_all_people contact
356: ,per_phones pho
357: WHERE rel.person_id = g_person_id
358: AND contact_type in ('EMRG','EC')
359: AND rel.contact_person_id = contact.person_id
360: AND p_sr_report_date between contact.effective_start_date AND contact.effective_end_date
362: AND pho.parent_id(+) = contact.person_id
363: AND p_sr_report_date BETWEEN NVL(pho.date_from,p_sr_report_date) AND NVL(pho.date_to,p_sr_report_date)
364: AND ((pho.phone_type = 'M'
365: AND NOT EXISTS (SELECT 1
366: FROM per_phones pho2
367: WHERE pho2.parent_id = pho.parent_id
368: AND pho2.phone_type IN ('H1','W1')
369: )
370: )
369: )
370: )
371: OR (pho.phone_type = 'W1'
372: AND NOT EXISTS (SELECT 1
373: FROM per_phones pho2
374: WHERE pho2.parent_id = pho.parent_id
375: AND pho2.phone_type = 'H1'
376: )
377: )