客户导入后需要Update的字段
客户及地址导入成功后,需要回头来update,脚本如下:
UPDATE ar.hz_cust_site_uses_all hcsu
SET hcsu.primary_salesrep_id = (SELECT rs.salesrep_id
FROM jtf_rs_salesreps rs
WHERE SYSDATE BETWEEN nvl(start_date_active, SYSDATE) AND
nvl(end_date_active, SYSDATE)
AND nvl(status, 'A') = 'A'
AND rs.org_id = hcsu.org_id
AND rs.NAME = c3.sale_person),
hcsu.freight_term = (SELECT ol.lookup_code
FROM oe_lookups ol
WHERE ol.lookup_type = 'FREIGHT_TERMS'
AND ol.enabled_flag = 'Y'
AND ol.meaning = c3.freight_method),
hcsu.payment_term_id = (SELECT rt.term_id
FROM ra_terms rt
WHERE SYSDATE BETWEEN nvl(rt.start_date_active, SYSDATE) AND
nvl(rt.end_date_active, SYSDATE + 1)
AND rt.NAME = c3.pay_method),
hcsu.territory_id = (SELECT rtk.territory_id
FROM ra_territories_kfv rtk
WHERE rtk.concatenated_segments = c3.sale_region
AND rtk.enabled_flag = 'Y')
WHERE hcsu.site_use_id =:p_site_use_id;