Это все о работе с архитектурой торгового сообщества
Посмотрите, как таблица hz_relationships используется для передачи этой информации. Следующий запрос работает для среды EBS R12.2 (12.1), где контакты создаются на уровне учетной записи (EBS R12 допускает как на уровне учетной записи, так и на уровне сайта, Форма клиента, Контакты / Связь: Устранение неполадок, Как, Известные проблемы и исправления (Doc ID 1456319.1 ).
SELECT
hca.account_number cust_account_number,
obj.party_name customer_name,
sub.party_name contact_name,
hps.party_site_number,
hcp.contact_point_type,
hcp.phone_number,
hcp.email_address
FROM
apps.hz_cust_accounts hca
JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
JOIN apps.hz_parties obj ON hca.party_id = obj.party_id
AND obj.party_type = 'ORGANIZATION'
JOIN apps.hz_relationships rel ON hca.party_id = rel.object_id
AND rel.relationship_type = 'CONTACT'
AND rel.directional_flag = 'F'
JOIN apps.hz_parties sub ON rel.subject_id = sub.party_id
AND sub.party_type = 'PERSON'
JOIN apps.hz_contact_points hcp ON rel.party_id = hcp.owner_table_id
AND hcp.owner_table_name = 'HZ_PARTIES'
JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
WHERE
hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hcp.contact_point_type IN (
'PHONE',
'EMAIL'
)
ORDER BY
2,
3
;
В этом запросе рассматриваются контакты, настроенные на уровне сайта (контакты клиентов):
SELECT
hca.account_number cust_account_number,
obj.party_name customer_name,
sub.party_name contact_name,
hps.party_site_number,
hcp.contact_point_type,
hcp.phone_number,
hcp.email_address
FROM
apps.hz_cust_accounts hca
JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
JOIN apps.hz_parties obj ON hps.party_id = obj.party_id
AND obj.party_type = 'ORGANIZATION'
JOIN apps.hz_relationships rel ON rel.object_id = obj.party_id
AND rel.relationship_type = 'CONTACT'
AND rel.directional_flag = 'F'
JOIN apps.hz_parties sub ON rel.subject_id = sub.party_id
AND sub.party_type = 'PERSON'
JOIN apps.hz_contact_points hcp ON rel.party_id = hcp.owner_table_id
AND hcp.owner_table_name = 'HZ_PARTIES'
WHERE
hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hcp.contact_point_type IN (
'PHONE',
'EMAIL'
)
ORDER BY
2,
Сведение вниззапросите немного дальше, можно просто сосредоточиться на контактной информации, не обращая внимания на тип контакта:
SELECT
obj.party_name,
sub.party_name contact_name,
hcp.contact_point_type,
hcp.phone_number,
hcp.email_address
FROM
apps.hz_parties obj
JOIN apps.hz_relationships rel ON rel.object_id = obj.party_id
AND rel.relationship_type = 'CONTACT'
AND rel.directional_flag = 'F'
JOIN apps.hz_parties sub ON rel.subject_id = sub.party_id
JOIN apps.hz_contact_points hcp ON rel.party_id = hcp.owner_table_id
AND hcp.owner_table_name = 'HZ_PARTIES'
WHERE
1 = 1
AND hcp.contact_point_type IN (
'PHONE',
'EMAIL'
)
ORDER BY
2,
3;