2016-06-30 7 views
0
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<ns4:EligibilityRequest xmlns:ns1="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/mmiscommon" xmlns:ns4="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest" xmlns:ns3="http://xmlns.eohhs.ma.gov/newMMIS/ws/2006/05/MemberInfo" xmlns:ns5="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligresponse"> 
    <ns4:transactionsource id_source="HIX" id_other="00000004353" id_medicaid="100208425271"/> 
    <ns4:demographic cde_born_to_st_empl=" " cde_born_to_ma=" " ind_pregnancy=" " pct_income_fpl="125" amt_income_fpl="1556.57" amt_indv_income="1638.5" amt_indv_prem="0" mail_adr_zip_code="02532" mail_adr_state="MA" mail_adr_city="Boston" mail_adr_street_2="APT 56" mail_adr_street_1="112 Main ST" res_adr_zip_code="02532" res_adr_state="MA" res_adr_city="Boston" res_adr_street_2="APT 56" res_adr_street_1="112 Main ST" nam_first="John" nam_last="Father" email="[email protected]" num_phone_day="8575550056" cde_lang_written="RUSSIN" cde_primary_lang="RUSSIN" cde_disability_stat=" " cde_homeless="N" cde_ethnicity="UNKNOW" cde_race="UNKNOW" cde_citizen="C" num_primary_ssn="278938115" cde_sex="M" dte_birth="1978-09-09"/> 
    <ns4:case amt_family_prem_assist="0" amt_family_mh_prem="0" amt_family_prem="0" hoh_nam_last="Father" hoh_nam_first="John" cde_case_status="2" num_case="00003235C"/> 
    <ns4:eligibility cde_office="555" cde_region="58" dte_appl="2014-11-13" family_size="2" amt_gross_income="1556.57" cde_cat="D1" cde_elig_status="4" cde_line="00" dte_end_elig="2014-11-13" dte_begin_elig="2014-11-03"/> 
    <ns4:eligibility cde_open_reason="01" cde_office="555" cde_region="58" dte_appl="2014-11-13" family_size="2" amt_gross_income="1556.57" cde_cat="D1" cde_elig_status="1" cde_line="00" dte_begin_elig="2014-11-03"/> 
</ns4:EligibilityRequest> 

aktualisieren Wenn Sie diese angebracht XML öffnen, können Sie sich 2 Tags von < ns4:eligibilityXML wählen und

sehen ich muß zuerst diesen letzten Teil Zeichenfolge wählen, entweder durch REGEXP_SUBSTR oder einfach str .. Mittel Ausgabe sollte sein:

<ns4:eligibility cde_open_reason="01" cde_office="555" cde_region="58" dte_appl="2014-11-13" family_size="2" amt_gross_income="1556.57" cde_cat="D1" cde_elig_status="1" cde_line="00" dte_begin_elig="2014-11-03"/> 

Dann fügen Sie diese Zeichenfolge an ein anderes XML. So wie das. nur zuletzt anhängen.

+0

Bitte geben Sie die XML enthalten. – bated

Antwort

2

Oracle-Setup:

CREATE TABLE XML_IN (id INT, xml CLOB); 
INSERT INTO XML_IN VALUES (1, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<ns4:EligibilityRequest xmlns:ns1="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/mmiscommon" xmlns:ns4="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest" xmlns:ns3="http://xmlns.eohhs.ma.gov/newMMIS/ws/2006/05/MemberInfo" xmlns:ns5="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligresponse"> 
    <ns4:transactionsource id_source="HIX" id_other="00000004353" id_medicaid="100208425271"/> 
    <ns4:demographic cde_born_to_st_empl=" " cde_born_to_ma=" " ind_pregnancy=" " pct_income_fpl="125" amt_income_fpl="1556.57" amt_indv_income="1638.5" amt_indv_prem="0" mail_adr_zip_code="02532" mail_adr_state="MA" mail_adr_city="Boston" mail_adr_street_2="APT 56" mail_adr_street_1="112 Main ST" res_adr_zip_code="02532" res_adr_state="MA" res_adr_city="Boston" res_adr_street_2="APT 56" res_adr_street_1="112 Main ST" nam_first="John" nam_last="Father" email="[email protected]" num_phone_day="8575550056" cde_lang_written="RUSSIN" cde_primary_lang="RUSSIN" cde_disability_stat=" " cde_homeless="N" cde_ethnicity="UNKNOW" cde_race="UNKNOW" cde_citizen="C" num_primary_ssn="278938115" cde_sex="M" dte_birth="1978-09-09"/> 
    <ns4:case amt_family_prem_assist="0" amt_family_mh_prem="0" amt_family_prem="0" hoh_nam_last="Father" hoh_nam_first="John" cde_case_status="2" num_case="00003235C"/> 
    <ns4:eligibility cde_office="555" cde_region="58" dte_appl="2014-11-13" family_size="2" amt_gross_income="1556.57" cde_cat="D1" cde_elig_status="4" cde_line="00" dte_end_elig="2014-11-13" dte_begin_elig="2014-11-03"/> 
    <ns4:eligibility cde_open_reason="01" cde_office="555" cde_region="58" dte_appl="2014-11-13" family_size="2" amt_gross_income="1556.57" cde_cat="D1" cde_elig_status="1" cde_line="00" dte_begin_elig="2014-11-03"/> 
</ns4:EligibilityRequest>'); 

CREATE TABLE XML_OUT(id INT, xml CLOB); 
INSERT INTO XML_OUT VALUES (1, '<test><attribute>existing</attribute></test>'); 

Abfrage:

MERGE INTO XML_OUT o 
USING XML_IN i ON (o.id = i.id) 
WHEN MATCHED THEN 
UPDATE 
    SET xml = APPENDCHILDXML(
       XMLType(o.xml), 
       '/test', 
       EXTRACT(
        XMLType(i.xml), 
        '//ns4:EligibilityRequest/ns4:eligibility[last()]', 
        'xmlns:ns4="http://newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest"' 
       ) 
      ).getClobVal(); 

Ausgang:

SELECT * FROM XML_OUT; 

     ID XML 
---------- ---------------------------------------------------------------------- 
     1 <test><attribute>existing</attribute><ns4:eligibility xmlns:ns4="http: 
      //newmmis.eohhs.ma.gov/serviceobjects/versions/1.0/eligrequest" cde_ope 
      n_reason="01" cde_office="555" cde_region="58" dte_appl="2014-11-13" fa 
      mily_size="2" amt_gross_income="1556.57" cde_cat="D1" cde_elig_status=" 
      1" cde_line="00" dte_begin_elig="2014-11-03"/></test>