客户表结构SQL语句

1. 客户主数据SQL:

  

[c-sharp]  view plain copy
  1. SELECT hca.cust_account_id     customer_id,  
  2.              hp.party_number         customer_number,  
  3.              hp.party_name           customer_name,  
  4.              hp.party_name           customer_short_name,  
  5.              hca.customer_type       customer_type,  
  6.              alt.meaning             customer_type_meaning,  
  7.              hca.customer_class_code customer_class,  
  8.              alc.meaning             customer_class_meaning,  
  9.              hp.tax_reference        tax_registered_name,  
  10.              rt.name                 term_name,  
  11.              hca.creation_date       creation_date,  
  12.              hca.created_by          created_by,  
  13.              hca.last_update_date    last_update_date,  
  14.              hca.last_updated_by     last_updated_by,  
  15.              hca.last_update_login   last_update_login  
  16.         FROM hz_parties           hp,  
  17.              hz_cust_accounts     hca,  
  18.              ar_lookups           alt,  
  19.              ar_lookups           alc,  
  20.              hz_customer_profiles hcp,  
  21.              ra_terms             rt  
  22.        WHERE hp.party_id               = hca.party_id  
  23.          AND hca.customer_type         = alt.lookup_code(+)  
  24.          AND alt.lookup_type           = 'CUSTOMER_TYPE'  
  25.          AND hca.customer_class_code   = alc.lookup_code(+)  
  26.          AND alc.lookup_type(+)        = 'CUSTOMER CLASS'  
  27.          AND hca.cust_account_id       = hcp.cust_account_id(+)  
  28.          AND hcp.standard_terms        = rt.term_id(+)  

 

2. 客户收款方法SQL:

 

[c-sharp]  view plain copy
  1. SELECT arm.name receipt_method_name  
  2.        FROM hz_cust_accounts        hca,  
  3.             ra_cust_receipt_methods rcrm,  
  4.             ar_receipt_methods      arm  
  5.       WHERE hca.cust_account_id    = rcrm.customer_id  
  6.         AND rcrm.receipt_method_id = arm.receipt_method_id  
  7.         AND hca.cust_account_id    = p_customer_id  
  8.       ORDER BY rcrm.creation_date;  

 

3. 客户账户层银行账户信息SQL:

 

[c-sharp]  view plain copy
  1. SELECT hca.cust_account_id   cust_account_id,  
  2.              hp.party_id           party_id,  
  3.              bank.party_id         bank_id,  
  4.              bank.party_name       bank_name,  
  5.              branch.party_id       branch_id,  
  6.              branch.party_name     bank_branch_name,  
  7.              ieba.bank_account_num bank_account_num  
  8.         FROM hz_cust_accounts      hca,  
  9.              hz_parties            hp,  
  10.              iby_account_owners    iao,  
  11.              iby_ext_bank_accounts ieba,  
  12.              hz_parties            bank,  
  13.              hz_parties            branch  
  14.        WHERE hca.party_id            = hp.party_id  
  15.          AND hp.party_id             = iao.account_owner_party_id(+)  
  16.          AND iao.ext_bank_account_id = ieba.ext_bank_account_id(+)  
  17.          AND ieba.bank_id            = bank.party_id(+)  
  18.          AND ieba.branch_id          = branch.party_id(+)  
  19.          AND hca.cust_account_id     = p_customer_id  
  20.        ORDER BY ieba.creation_date;               

 

4. 客户开户行地址信息SQL:

 

[c-sharp]  view plain copy
  1. SELECT hl.country  || '-' ||   
  2.              hl.province || '-' ||   
  3.              hl.city     || '-' ||  
  4.              hl.address1 || '-' ||   
  5.              hl.address2 || '-' ||   
  6.              hl.address3 || '-' ||  
  7.              hl.address4 bank_address  
  8.         FROM hz_party_sites hps,   
  9.              hz_locations   hl  
  10.        WHERE hps.location_id = hl.location_id  
  11.          AND hps.party_id    = p_bank_id  
  12.        ORDER BY hps.creation_date;  

 

5. 客户账户层联系人信息:联系人、电话、手机和Email SQL:

[c-sharp]  view plain copy
  1. SELECT hr.party_id            party_id,  
  2.              hcar.cust_account_id   cust_account_id,  
  3.              hcar.cust_acct_site_id cust_acct_site_id,  
  4.              hp.person_last_name   || ' ' ||   
  5.              hp.person_middle_name || ' ' ||  
  6.              hp.person_first_name   contact_person,  
  7.              hcpp.phone_area_code   phone_area_code,  
  8.              hcpp.phone_number      phone_number,  
  9.              hcpp.phone_extension   phone_extension,  
  10.              hcpm.phone_area_code   mobile_phone_area_code,  
  11.              hcpm.phone_number      mobile_phone_number,  
  12.              hcpe.email_address     email_address  
  13.         FROM hz_relationships      hr,  
  14.              hz_cust_account_roles hcar,  
  15.              hz_org_contacts       hoc,  
  16.              hz_contact_points     hcpp,  
  17.              hz_contact_points     hcpm,  
  18.              hz_contact_points     hcpe,  
  19.              hz_parties            hp,  
  20.              hz_cust_accounts      hca  
  21.        WHERE hr.object_id               = hp.party_id  
  22.          AND hr.party_id                = hcar.party_id  
  23.          AND hr.relationship_id         = hoc.party_relationship_id(+)  
  24.          AND hcpp.owner_table_id(+)     = hr.party_id  
  25.          AND hcpm.owner_table_id(+)     = hr.party_id  
  26.          AND hcpe.owner_table_id(+)     = hr.party_id  
  27.          AND hr.object_type             = 'PERSON'  
  28.          AND hr.relationship_code(+)    = 'CONTACT'  
  29.          AND hcpp.owner_table_name(+)   = 'HZ_PARTIES'  
  30.          AND hcpm.owner_table_name(+)   = 'HZ_PARTIES'  
  31.          AND hcpe.owner_table_name(+)   = 'HZ_PARTIES'  
  32.          AND hcpp.contact_point_type(+) = 'PHONE'  
  33.          AND hcpp.phone_line_type(+)    = 'GEN'  
  34.          AND hcpm.contact_point_type(+) = 'PHONE'  
  35.          AND hcpm.phone_line_type(+)    = 'MOBILE'  
  36.          AND hcpe.contact_point_type(+) = 'EMAIL'  
  37.          AND hcpe.phone_line_type       IS NULL  
  38.          AND hr.subject_id              = hca.party_id  
  39.          AND hcar.cust_acct_site_id     IS NULL  
  40.          AND hca.cust_account_id        = p_customer_id  
  41.        ORDER BY hr.creation_date;  

 

6. 客户地址SQL:

 

[c-sharp]  view plain copy
  1. SELECT hcasa.cust_acct_site_id customer_site_id,  
  2.             hcasa.cust_account_id   customer_id,  
  3.             hps.party_site_number   customer_site_code,  
  4.             hps.party_site_name     customer_site_name,  
  5.             hl.address1             address_line1,  
  6.             hl.address2             address_line2,  
  7.             hl.address3             address_line3,  
  8.             hl.address4             address_line4,  
  9.             hcasa.org_id            org_id,  
  10.             hl.country              country,  
  11.             hl.province             province,  
  12.             hl.city                 city,  
  13.             hl.county               county,  
  14.             hl.postal_code          zip,  
  15.             hcasa.bill_to_flag      bill_to_flag,  
  16.             hcasa.ship_to_flag      ship_to_flag,  
  17.             hca.creation_date       creation_date,  
  18.             hca.created_by          created_by,  
  19.             hca.last_update_date    last_update_date,  
  20.             hca.last_updated_by     last_updated_by,  
  21.             hca.last_update_login   last_update_login  
  22.        FROM hz_cust_accounts       hca,  
  23.             hz_cust_acct_sites_all hcasa,  
  24.             hz_party_sites         hps,  
  25.             hz_locations           hl  
  26.       WHERE hca.cust_account_id = hcasa.cust_account_id  
  27.         AND hcasa.party_site_id = hps.party_site_id  
  28.         AND hps.location_id     = hl.location_id  
  29.         AND hca.cust_account_id = p_customer_id; --客户地址基本信息表  

 

7. 客户账户层地址contact person信息:phone,mobile,email SQL:

[c-sharp]  view plain copy
  1. SELECT hr.party_id            party_id,  
  2.              hcar.cust_account_id   cust_account_id,  
  3.              hcar.cust_acct_site_id cust_acct_site_id,  
  4.              hp.person_last_name   || ' ' ||   
  5.              hp.person_middle_name || ' ' ||  
  6.              hp.person_first_name   contact_person,  
  7.              hcpp.phone_area_code   phone_area_code,  
  8.              hcpp.phone_number      phone_number,  
  9.              hcpp.phone_extension   phone_extension,  
  10.              hcpm.phone_area_code   mobile_phone_area_code,  
  11.              hcpm.phone_number      mobile_phone_number,  
  12.              hcpe.email_address     email_address  
  13.         FROM hz_relationships      hr,  
  14.              hz_cust_account_roles hcar,  
  15.              hz_org_contacts       hoc,  
  16.              hz_contact_points     hcpp,  
  17.              hz_contact_points     hcpm,  
  18.              hz_contact_points     hcpe,  
  19.              hz_parties            hp,  
  20.              hz_cust_accounts      hca  
  21.        WHERE hr.object_id               = hp.party_id  
  22.          AND hr.party_id                = hcar.party_id  
  23.          AND hr.relationship_id         = hoc.party_relationship_id(+)  
  24.          AND hcpp.owner_table_id(+)     = hr.party_id  
  25.          AND hcpm.owner_table_id(+)     = hr.party_id  
  26.          AND hcpe.owner_table_id(+)     = hr.party_id  
  27.          AND hr.object_type             = 'PERSON'  
  28.          AND hr.relationship_code(+)    = 'CONTACT'  
  29.          AND hcpp.owner_table_name(+)   = 'HZ_PARTIES'  
  30.          AND hcpm.owner_table_name(+)   = 'HZ_PARTIES'  
  31.          AND hcpe.owner_table_name(+)   = 'HZ_PARTIES'  
  32.          AND hcpp.contact_point_type(+) = 'PHONE'  
  33.          AND hcpp.phone_line_type(+)    = 'GEN'  
  34.          AND hcpm.contact_point_type(+) = 'PHONE'  
  35.          AND hcpm.phone_line_type(+)    = 'MOBILE'  
  36.          AND hcpe.contact_point_type(+) = 'EMAIL'  
  37.          AND hcpe.phone_line_type       IS NULL  
  38.          AND hr.subject_id              = hca.party_id  
  39.          AND hca.cust_account_id        = hcar.cust_account_id  
  40.          AND hca.cust_account_id        = p_customer_id  
  41.          AND hcar.cust_acct_site_id     = p_customer_site_id  
  42.        ORDER BY hr.creation_date;  

 

8. 客户账户地点地址SQL:

  

[c-sharp]  view plain copy
  1. SELECT hp.party_id,  
  2.        hca.cust_account_id,  
  3.        hcasa.cust_acct_site_id,  
  4.        hcasa.bill_to_flag,  
  5.        hcasa.ship_to_flag,  
  6.        hcsua.site_use_id,  
  7.        hcasa.party_site_id,  
  8.        hcsua.site_use_code,  
  9.        hcsua.primary_flag,  
  10.        hcsua.location, hcsua.org_id  
  11.   FROM hz_parties             hp,  
  12.        hz_cust_accounts       hca,  
  13.        hz_party_sites         hps,  
  14.        hz_cust_acct_sites_all hcasa,  
  15.        hz_cust_site_uses_all  hcsua  
  16.  WHERE hp.party_id = hca.party_id  
  17.    AND hca.cust_account_id = hcasa.cust_account_id  
  18.    AND hcasa.party_site_id = hps.party_site_id  
  19.    AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id  

 

9 客户主配置文件SQL:

  

[c-sharp]  view plain copy
  1. SELECT * FROM hz_cust_profile_classes;   
  2. SELECT * FROM hz_customer_profiles;  
  3. SELECT * FROM hz_cust_prof_class_amts;  
  4. SELECT * FROM hz_cust_profile_amts;    

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值