注意::该主题适用于了解Oracle EBS的人员(开发人员或程序员)
由于某种原因,我一直试图获取存储在HZ_PARTIES BUT中的联系信息,这表明电子邮件为NULL,并且那是不正确的(如果我将HZ_PARTY_SITES代替HZ_PARTIES,我的查询就可以了,但是它没有显示该信息我想要的)
每次创建客户时,都会执行此过程:
https://www.codepile.net/pile/9nzMKy4D
根据上面显示的信息,我进行了以下查询:
SELECT
hp.party_name
, hca.account_number
, hcp.phone_number
, hcp.email_address
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_site hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTIES'
AND contact_point_type IN ('EMAIL','PHONE')
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
--AND hca.account_number = 'account_number'
;
看看这张图片(我还不能上传图片):
您能帮我解决这个问题吗?
编辑:我正在连接到Oracle数据库(11g)
答案 0 :(得分:0)
这就是与交易社区体系结构一起使用的全部
查看如何使用hz_relationships表来引入此信息。以下查询适用于在帐户级别创建联系人的EBS R12.2环境(12.1数据库)(EBS R12允许在帐户级别和网站级别Customer Form, Contacts/Communication: Troubleshooting, How To, Known Issues and Patches (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;
答案 1 :(得分:0)
“派对”和“派对网站”级别的联系人列表,类型为“电子邮件”和“电话号码”。
SELECT DISTINCT hp.party_id,
hp.party_name,
hca.cust_account_id,
hca.account_number,
party_site_id,
party_site_number,
hcp.phone_number,
NVL (hcp.email_address, hcp.url) email_or_url,
hcp.contact_point_type communication_type,
hcp.status active,
hcp.contact_point_purpose purpose
FROM apps.hz_contact_points hcp,
apps.hz_party_sites hps,
apps.hz_cust_accounts hca,
apps.hz_parties hp
WHERE hps.party_id = hca.party_id
AND hp.party_id = hca.party_id
AND hcp.contact_point_type IN ('PHONE','EMAIL')
AND hcp.owner_table_name = 'HZ_PARTIES'
AND hcp.owner_table_id = hps.party_id
AND hcp.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hp.status = 'A'
UNION
SELECT DISTINCT hp.party_id,
hp.party_name,
hca.cust_account_id,
hca.account_number,
party_site_id,
party_site_number,
hcp.phone_number,
NVL (hcp.email_address, hcp.url) email_or_url,
hcp.contact_point_type communication_type,
hcp.status active,
hcp.contact_point_purpose purpose
FROM apps.hz_contact_points hcp,
apps.hz_party_sites hps,
apps.hz_cust_accounts hca,
apps.hz_parties hp
WHERE hps.party_id = hca.party_id
AND hp.party_id = hca.party_id
AND hcp.contact_point_type IN ('PHONE','EMAIL')
AND hcp.owner_table_name = 'HZ_PARTY_SITES'
AND hcp.owner_table_id = hps.party_site_id
AND hcp.status = 'A'
AND hps.status = 'A'
AND hp.status = 'A'
AND hca.status = 'A';