Oracle ERP AP模组中Vender 联系人信息查询语句

##Oracle ERP AP模组中Vender 联系人信息查询语句

‘create or replace view Q_ap_s_cont as
select pv.vendor_id vendor_id,
pvs.vendor_site_id vendor_site_id,
hp.person_first_name c_first_name,
hp.person_last_name c_last_name,
hp.person_title c_person_title,
hcpe.email_address c_email_address,
hcpp.phone_area_code c_phone_area_code,
hcpp.phone_number c_phone_number,
hcpf.phone_area_code c_fax_area_code,
hcpf.phone_number c_fax_number
from hz_parties hp
, hz_relationships hzr,
hz_contact_points hcpp,
hz_contact_points hcpf,
hz_contact_points hcpe,
ap_suppliers pv,
ap_supplier_sites_all pvs,
hz_party_sites hps
where hp.party_id = hzr.subject_id
and hzr.relationship_type = ‘CONTACT’
and hzr.relationship_code = ‘CONTACT_OF’
and hzr.subject_type = ‘PERSON’
and hzr.subject_table_name = ‘HZ_PARTIES’
and hzr.object_type = ‘ORGANIZATION’
and hzr.object_table_name = ‘HZ_PARTIES’
and hzr.status = ‘A’
and hcpp.owner_table_name(+) = ‘HZ_PARTIES’
and hcpp.owner_table_id(+) = hzr.party_id
and hcpp.phone_line_type(+) = ‘GEN’
and hcpp.contact_point_type(+) = ‘PHONE’
and hcpf.owner_table_name(+) = ‘HZ_PARTIES’
and hcpf.owner_table_id(+) = hzr.party_id
and hcpf.phone_line_type(+) = ‘FAX’
and hcpf.contact_point_type(+) = ‘PHONE’
and hcpe.owner_table_name(+) = ‘HZ_PARTIES’
and hcpe.owner_table_id(+) = hzr.party_id
and hcpe.contact_point_type(+) = ‘EMAIL’
and hcpp.status (+)=‘A’
and hcpf.status (+)=‘A’
and hcpe.status (+)=‘A’
and hps.party_id = hzr.object_id
and pvs.party_site_id = hps.party_site_id
and pv.vendor_id = pvs.vendor_id
and exists
( select 1
from ap_supplier_contacts ascs
where (ascs.inactive_date is null
or ascs.inactive_date > sysdate)
and hzr.relationship_id = ascs.relationship_id
and hzr.party_id = ascs.rel_party_id
and hps.party_site_id = ascs.org_party_site_id
and hzr.subject_id = ascs.per_party_id
)
–and pv.vendor_id in (select vendor_id from vendors);

你可能感兴趣的:(Oracle,EBS,sql,oracle)