Friday, May 19, 2017

R12 Query for Supplier Information

select sup.vendor_id

, sup.vendor_name

, site.vendor_site_code

, site.inactive_date

, area_code || ' ' || phone phone_number

, fax_area_code || ' ' || fax fax_number

, telex /* who uses it now*/

, site.address_line1 ||

decode(site.address_line2, null, null, ', ' || address_line2) || ' ' ||

site.city || ', ' ||

site.state || '-' ||

site.zip || ' ' ||

decode(site.county, null, null, ', ' || site.county || ' ') ||

site.country Address

, (select loc.address1 ||

decode(loc.address2, null, null, ', ' || loc.address2) || ' ' ||

loc.city || ', ' ||

loc.state || '-' ||

loc.postal_code || ' ' ||

decode(loc.county, null, null, ', ' || loc.county || ' ') ||

loc.country

from hz_party_sites psite

, hz_locations loc

where psite.party_site_id = site.party_site_id

and psite.location_id = loc.location_id

) address_based_on_party_site

, (select '(' || phone.phone_area_code || ') ' || phone.phone_number

from hz_contact_points phone

where phone.owner_table_id = site.party_site_id

and phone.owner_table_name = 'HZ_PARTY_SITES'

and phone.phone_line_type = 'GEN'

) phone_number

, (select '(' || fax.phone_area_code || ') ' || fax.phone_number

from hz_contact_points fax

where fax.owner_table_id = site.party_site_id

and fax.owner_table_name = 'HZ_PARTY_SITES'

and fax.phone_line_type = 'FAX'

) fax_number

, (select email.email_address

from hz_contact_points email

where email.owner_table_id = site.party_site_id

and email.owner_table_name = 'HZ_PARTY_SITES'

and contact_point_type = 'EMAIL'

) email_address

from ap_suppliers sup

, ap_supplier_sites_all site

where vendor_name like 'Bexxxxxxxx'

and sup.vendor_id = site.vendor_id

and VENDOR_SITE_CODE='001'




;