1. 程式人生 > >R12客戶表結構分析

R12客戶表結構分析

select org.name
  
from hr_organization_units org
 
where org.organization_id = oe_order_headers_all.sold_from_org_id;   
 
--客戶select hz.party_name
  
from hz_cust_accounts acc,
       hz_parties       hz
 
where acc.party_id = hz.party_id
   
and acc.cust_account_id = oe_order_headers_all.sold_to_org_id; 
   
--發貨倉庫select para.organization_code,
       para.
*from mtl_parameters para
 
where para.organization_id = oe_order_headers_all.ship_from_org_id;

select*from org_organization_definitions org
 
where org.organization_id = oe_order_headers_all.ship_from_org_id;
 
--地點詳細資訊select loc.*from hz_parties     hp,
       hz_party_sites hps,
       hz_locations   loc
 
where hp.party_id = hps.party_id
   
and hps.location_id = loc.location_id
   
and hp.party_id =5042;
   
--業務目的select hp.party_name --客戶      ,
       hp.party_number 
--登錄檔標識      ,
       uses.site_use_code,
       acnt.account_number 
--賬號      ,
       flv.meaning businesspurpose 
--業務目的      ,
       uses.location 
--地點      ,
       acnt.account_name 
--帳戶說明      ,
       decode(loc.address1, 
null, loc.address1, loc.address1 ||','||
       decode(loc.city, 
null, loc.city, loc.city ||','||
       decode(loc.state, 
null, loc.state, loc.state ||','||
       decode(loc.postal_code, 
null'', loc.postal_code) address --地點地址      ,
       hps.party_site_number 
--地點說明      ,
       uses.payment_term_id 
--付款條件      ,
       site.cust_acct_site_id,
       acnt.cust_account_id,
       uses.site_use_id
  
from hz_parties             hp,
       hz_cust_accounts       acnt,
       hz_cust_acct_sites_all site,
       hz_cust_site_uses_all  uses,
       hz_party_sites         hps,
       hz_locations           loc,
       fnd_lookup_values      flv
 
where hp.party_id = acnt.party_id
   
and acnt.cust_account_id = site.cust_account_id
   
and site.cust_acct_site_id = uses.cust_acct_site_id
   
and hps.party_site_id = site.party_site_id
   
and loc.location_id = hps.location_id
   
and uses.site_use_code = flv.lookup_code
   
and flv.lookup_type ='SITE_USE_CODE'and flv.language = userenv('LANG')
   
and hp.party_id =5042and hps.party_site_id =3023;
   
--聯絡人電話/地點層select phone.phone_number
  
from hz_contact_points phone
 
where phone.owner_table_name ='HZ_PARTY_SITES'and phone.owner_table_id = :hz_party_sites.party_sites_id;
   
--聯絡人/地點層select hpsub.party_name
  
from hz_cust_account_roles hcar,
       hz_relationships      hr,
       hz_parties            hpsub
 
where hcar.party_id = hr.party_id
   
and hr.subject_id = hpsub.party_id
   
and hcar.role_type ='CONTACT'and hr.directional_flag ='F'and hcar.cust_account_role_id = :oe_order_headers_all.sold_to_contact_id
   
and hpsub.status ='A';