税的取数SQL

1. 取供应商税码

    FUNCTION get_tax_classification_code( p_party_id IN NUMBER ) RETURN VARCHAR2 IS l_tax_classification_code VARCHAR2(100); BEGIN SELECT tax_classification_code INTO l_tax_classification_code FROM zx_party_tax_profile WHERE party_id = p_party_id AND party_type_code = 'THIRD_PARTY'; RETURN l_tax_classification_code; EXCEPTION WHEN OTHERS THEN RETURN NULL; END; --取供应商税码 l_tax_classification_code := get_tax_classification_code(rec_header.vendor_id);

 

2. 取得供应商地点层税率
    FUNCTION get_vendor_tax(p_vendor_id IN NUMBER, p_vendor_site_id IN NUMBER) RETURN NUMBER IS v_vendor_tax NUMBER; BEGIN SELECT zxr.percentage_rate INTO v_vendor_tax FROM po_vendor_sites_all pvs, zx_party_tax_profile ztp, hz_code_assignments hca, zx_mco_eo_rates_v zxr WHERE ztp.party_id = pvs.party_site_id AND hca.owner_table_id = ztp.party_tax_profile_id AND hca.owner_table_name = 'ZX_PARTY_TAX_PROFILE' AND (hca.start_date_active <= SYSDATE OR hca.start_date_active IS NULL) AND (hca.end_date_active > SYSDATE OR hca.end_date_active IS NULL) AND zxr.tax_rate_code = hca.class_code AND (zxr.effective_from <= SYSDATE OR zxr.effective_from IS NULL) AND (zxr.effective_to > SYSDATE OR zxr.effective_to IS NULL) AND pvs.vendor_id = p_vendor_id AND pvs.vendor_site_id = p_vendor_site_id; RETURN v_vendor_tax; EXCEPTION WHEN OTHERS THEN RETURN 0; END;

你可能感兴趣的:(exception,Date,function,table,null,classification)