Parse XML stored in portions in VARCHAR2 (4000)

Hello

I have to query the data to a third party application, so do not blame me for the data :-) model

The XML is stored in a column VARCHAR2 (4000) and when there is more then 4000 characters, it is divided into parts with a sequence to identify the order.

Example:

DROP TABLE junk_xml;
CREATE TABLE junk_xml(
    id       INTEGER -- content id
   ,nr       INTEGER -- content sequence
   ,fragment VARCHAR2(4000)
   );
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,1,'<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02 camt.053.001.02.xsd">
    <BkToCstmrStmt>
        <GrpHdr>
            <MsgId>27632364572</MsgId>
            <CreDtTm>2008-09-01T19:30:47.0+01:00</CreDtTm>
            <MsgRcpt>
                <Id>
                    <OrgId>
                        <Othr>
                            <Id>BCS45678</Id>
                        </Othr>
                    </OrgId>
                </Id>
            </MsgRcpt>
            <MsgPgntn>
                <PgNb>1</PgNb>
                <LastPgInd>true</LastPgInd>
            </MsgPgntn>
        </GrpHdr>
        <Stmt>
            <Id>2736482736482</Id>
            <ElctrncSeqNb>101</ElctrncSeqNb>
            <LglSeqNb>32</LglSeqNb>
            <CreDtTm>2008-09-01T17:30:47.0+01:00</CreDtTm>
            <Acct>
                <Id>
                    <IBAN>DE62210500001234567890</IBAN>
                </Id>
                <Ccy>EUR</Ccy>
                <Ownr>
                    <Nm>Name Kontoinhaber</Nm>
                </Ownr>
                <Svcr>
                    <FinInstnId>
                        <BIC>BANKDEFFXXX</BIC>
                        <Othr>
                            <Id>123456789</Id>
                            <Issr>UmsStId</Issr>
                        </Othr>
                    </FinInstnId>
                </Svcr>
            </Acct>
            <Bal>
                <Tp>
                    <CdOrPrtry>
                        <Cd>PRCD</Cd>
                    </CdOrPrtry>
                </Tp>
                <Amt Ccy="EUR">112.72</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Dt>
                    <Dt>2008-09-01</Dt>
                </Dt>
            </Bal>
            <Bal>
                <Tp>
                    <CdOrPrtry>
                        <Cd>CLBD</Cd>
                    </CdOrPrtry>
                </Tp>
                <Amt Ccy="EUR">158780.32</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Dt>
                    <Dt>2008-09-01</Dt>
                </Dt>
            </Bal>
            <!-- Beispiel 1: SEPA-Zahlungen (Ueberweisung, Lastschrift, R-Nachricht -->
            <!--Gutschrift aufgrund eines SEPA-Ueberweisungseinganges-->
            <Ntry>
                <Amt Ccy="EUR">100.00</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-01</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-01</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <Refs>
                            <EndToEndId>');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,2,'Ende-zu-Ende-Id des Ueberweisenden</EndToEndId>
                        </Refs>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+166</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RltdPties>
                            <Dbtr>
                                <Nm>Herr Ueberweisender</Nm>
                            </Dbtr>
                            <DbtrAcct>
                                <Id>
                                    <IBAN>DE21500500001234567897</IBAN>
                                </Id>
                            </DbtrAcct>
                            <UltmtDbtr>
                                <Nm>Herr Debtor Reference Party</Nm>
                            </UltmtDbtr>
                            <Cdtr>
                                <Nm>Herr Kontoinhaber</Nm>
                            </Cdtr>
                            <UltmtCdtr>
                                <Nm>Herr Creditor Reference Party</Nm>
                            </UltmtCdtr>
                        </RltdPties>
                        <Purp>
                            <Cd>GDDS</Cd>
                        </Purp>
                        <RmtInf>
                            <Ustrd>Rechnungsnr. 4711 vom 20.08.2008</Ustrd>
                        </RmtInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>SEPA GUTSCHRIFT</AddtlNtryInf>
            </Ntry>
            <!--Gutschrift aufgrund einer zurueckgekommenen SEPA-Ueberweisung-->
            <Ntry>
                <Amt Ccy="EUR">200.00</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-01</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-01</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <Refs>
                            <EndToEndId>Urspr. E2E-Id der Hintransaktion</EndToEndId>
                        </Refs>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+159++901</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RmtInf>
                            <Ustrd>Angabe des urspruenglichen Verwendungszweckes</Ustrd>
                        </RmtInf>
                        <RtrInf>
                            <OrgnlBkTxCd>
                                <Prtry>
                                    <Cd>NTRF+116</Cd>
                                    <Issr>ZKA</Issr>
                                </Prtry>
                            </OrgnlBkTxCd>
                            <Orgtr>
                                <Id>
                                    <OrgId>
                                        <BICOrBEI>BANKDEHH</BICOrBEI>
                                    </OrgId>
                                </Id>
                            </Orgtr>
                            <Rsn>
                                <Cd>AC01</Cd>
                            </Rsn>
                            <AddtlInf>IBAN FEHLERHAFT</AddtlInf>
                        </RtrInf>
                    </TxDtls>');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,3,'
                </NtryDtls>
                <AddtlNtryInf>SEPA RUECKBUCHUNG</AddtlNtryInf>
            </Ntry>
            <!--Belastung aufgrund einer SEPA-Lastschrift-->
            <Ntry>
                <Amt Ccy="EUR">50.00</Amt>
                <CdtDbtInd>DBIT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-01</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-01</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <Refs>
                            <EndToEndId>E2E-Id vergeben vom Glaeubiger</EndToEndId>
                            <MndtId>Ref. des SEPA-Lastschriftmandats</MndtId>
                        </Refs>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NDDT+105</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RltdPties>
                            <Dbtr>
                                <Nm>Herr Zahlungspflichtiger</Nm>
                            </Dbtr>
                            <UltmtDbtr>
                                <Nm>Herr Debtor Reference Party</Nm>
                            </UltmtDbtr>
                            <Cdtr>
                                <Nm>Glaeubigerfirma</Nm>
                                <Id>
                                    <PrvtId>
                                        <Othr>
                                            <Id>Cdtr-Id des Glaeubigers</Id>
                                        </Othr>
                                    </PrvtId>
                                </Id>
                            </Cdtr>
                        </RltdPties>
                        <Purp>
                            <Cd>PHON</Cd>
                        </Purp>
                        <RmtInf>
                            <Ustrd>Telefonrechnung August 2009, Vertragsnummer 3536456345</Ustrd>
                        </RmtInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>SEPA LASTSCHRIFT</AddtlNtryInf>
            </Ntry>
            <!-- Beispiel 2: DTAUS-Zahlungen (Ueberweisung, Lastschrift, Rueckgabe) -->
            <!--Gutschrift aufgrund eines DTA-Überweisungseinganges-->
            <Ntry>
                <Amt Ccy="EUR">100.00</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-02</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-02</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz aus DTA C-Satz Feld 6</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+051++000</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RltdPties>
                            <Dbtr>');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,4,'
                                <Nm>Herr Überweisender</Nm>
                            </Dbtr>
                            <DbtrAcct>
                                <Id>
                                    <Othr>
                                        <Id>1234567890</Id>
                                    </Othr>
                                </Id>
                            </DbtrAcct>
                        </RltdPties>
                        <RmtInf>
                            <Ustrd>Rechnungsnr 4711 - Warenlieferung vom 20.08.2008</Ustrd>
                        </RmtInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>ÜBERWEISUNGSGUTSCHRIFT</AddtlNtryInf>
            </Ntry>
            <!--Gutschrift aufgrund einer zurückgekommenen DTA-Überweisung-->
            <Ntry>
                <Amt Ccy="EUR">200.00</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-02</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-02</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz aus DTA C-Satz Feld 6</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+059++511</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RmtInf>
                            <Ustrd>Angabe des ursprünglichen Verwendungszweckes</Ustrd>
                        </RmtInf>
                        <RtrInf>
                            <OrgnlBkTxCd>
                                <Prtry>
                                    <Cd>NTRF+051++000</Cd>
                                    <Issr>ZKA</Issr>
                                </Prtry>
                            </OrgnlBkTxCd>
                            <Orgtr>
                                <Nm>Herr Überweisungsempfänger</Nm>
                            </Orgtr>
                            <Rsn>
                                <Prtry>512</Prtry>
                            </Rsn>
                            <AddtlInf>BLZ 25069674 EXISTIERT NICHT</AddtlInf>
                        </RtrInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>RÜCKÜBERWEISUNG</AddtlNtryInf>
            </Ntry>
            <!--Belastung aufgrund einer DTA-Lastschrift-->
            <Ntry>
                <Amt Ccy="EUR">50</Amt>
                <CdtDbtInd>DBIT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-02</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-02</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz aus DTA C-Satz Feld 6</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+005++000</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        ');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,5,'<RltdPties>
                            <Cdtr>
                                <Nm>Telefongesellschaft ABC</Nm>
                            </Cdtr>
                        </RltdPties>
                        <RmtInf>
                            <Ustrd>Telefonrechnung August 2009, Vertragsnummer 3536456345</Ustrd>
                        </RmtInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>LASTSCHRIFT</AddtlNtryInf>
            </Ntry>
            <!-- Beispiel 3a: Sammlerdarstellung mit Aufloesung innerhalb der Nachricht -->
            <!--Belastung aufgrund von SEPA-Lastschriftrueckgaben (Sammelbuchung) mit Sammleraufloesung unter Transaction Details-->
            <Ntry>
                <Amt Ccy="EUR">276</Amt>
                <CdtDbtInd>DBIT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-03</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-03</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <!-- BkTxCd ist Pflichtfeld gemaess ISO, wird jedoch ausschliesslich auf Tx-Ebene verwendet -->
                <NtryDtls>
                    <Btch>
                        <NbOfTxs>3</NbOfTxs>
                    </Btch>
                    <TxDtls>
                        <!-- Ab hier Aufloesung des Sammlers bestehend aus 3 Einzelumsaetzen -->
                        <Refs>
                            <EndToEndId>79892</EndToEndId>
                            <MndtId>10001</MndtId>
                        </Refs>
                        <AmtDtls>
                            <TxAmt>
                                <Amt Ccy="EUR">76</Amt>
                            </TxAmt>
                        </AmtDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+109++901</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RltdPties>
                            <Dbtr>
                                <Nm>Herr Zahlungspflichtiger 1</Nm>
                            </Dbtr>
                            <Cdtr>
                                <Nm>Telefongesellschaft ABC</Nm>
                                <Id>
                                    <PrvtId>
                                        <Othr>
                                            <Id>CdtrId des SEPA-Lastschrifteinr.</Id>
                                        </Othr>
                                    </PrvtId>
                                </Id>
                            </Cdtr>
                        </RltdPties>
                        <Purp>
                            <Cd>PHON</Cd>
                        </Purp>
                        <RmtInf>
                            <Ustrd>Telefonrechnung August 2009, Vertragsnummer 3536456345</Ustrd>
                        </RmtInf>
                    </TxDtls>
                    <TxDtls>
                        <Refs>
                            <EndToEndId>768768</EndToEndId>
                            <MndtId>10002');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,6,'</MndtId>
                        </Refs>
                        <AmtDtls>
                            <TxAmt>
                                <Amt Ccy="EUR">80</Amt>
                            </TxAmt>
                        </AmtDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+109++901</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RltdPties>
                            <Dbtr>
                                <Nm>Herr Zahlungspflichtiger 2</Nm>
                            </Dbtr>
                            <Cdtr>
                                <Nm>Telefongesellschaft ABC</Nm>
                                <Id>
                                    <PrvtId>
                                        <Othr>
                                            <Id>CdtrId des SEPA-Lastschrifteinr.</Id>
                                        </Othr>
                                    </PrvtId>
                                </Id>
                            </Cdtr>
                        </RltdPties>
                        <Purp>
                            <Cd>PHON</Cd>
                        </Purp>
                        <RmtInf>
                            <Ustrd>Telefonrechnung August 2009, Vertragsnummer 3536456888</Ustrd>
                        </RmtInf>
                    </TxDtls>
                    <TxDtls>
                        <Refs>
                            <EndToEndId>45456465</EndToEndId>
                            <MndtId>10003</MndtId>
                        </Refs>
                        <AmtDtls>
                            <TxAmt>
                                <Amt Ccy="EUR">120</Amt>
                            </TxAmt>
                        </AmtDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+109++901</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <RltdPties>
                            <Dbtr>
                                <Nm>Herr Zahlungspflichtiger 3</Nm>
                            </Dbtr>
                            <Cdtr>
                                <Nm>Telefongesellschaft ABC</Nm>
                                <Id>
                                    <PrvtId>
                                        <Othr>
                                            <Id>CdtrId des SEPA-Lastschrifteinr.</Id>
                                        </Othr>
                                    </PrvtId>
                                </Id>
                            </Cdtr>
                        </RltdPties>
                        <Purp>
                            <Cd>PHON</Cd>
                        </Purp>
                        <RmtInf>
                            <Ustrd>Telefonrechnung August 2009, Vertragsnummer 3536456345</Ustrd>
                        </RmtInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>SEPA Direct Debit (Einzelbuchung-Soll, Core)</AddtlNtryInf>
            </Ntry>
            <!-- Beispiel 3b: Sammlerdarstellung mit Verweis auf pain-Nachricht und separate camt.054.001.01-Nachricht -->
            <!--Belastung aufgrund einer SEPA-Ueberweisung (Sammler) mit Verweis auf Original pain-Nachricht-->
            <Ntry>
                <Amt Ccy="');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,7,'EUR">100876.00</Amt>
                <CdtDbtInd>DBIT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-03</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-03</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <Btch>
                        <MsgId>MsgId der pain-Nachricht</MsgId>
                        <PmtInfId>Sammler-Id dieser pain-Nachricht</PmtInfId>
                    </Btch>
                    <TxDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+191</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>SEPA Credit Transfer (Sammler-Soll)</AddtlNtryInf>
            </Ntry>
            <!--Belastung aufgrund von SEPA-Lastschriftrueckgaben (Sammelbuchung) mit Verweis auf separate camt.054.001.01-Nachricht-->
            <Ntry>
                <Amt Ccy="EUR">276.00</Amt>
                <CdtDbtInd>DBIT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-03</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-03</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <AddtlInfInd>
                    <MsgNmId>camt.054.001.01</MsgNmId>
                    <MsgId>054-20090903-00034</MsgId>
                    <!-- siehe Bsp. camt54 Bsp 3b -->
                </AddtlInfInd>
                <NtryDtls>
                    <TxDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+109++901</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>SEPA Direct Debit (Einzelbuchung-Soll, Core)</AddtlNtryInf>
            </Ntry>
            <!-- Beispiel 4: USD-Zahlung mit Gutschrift auf einem EUR-Konto -->
            <!-- USD-Zahlung mit Gutschrift auf einem EUR-Konto -->
            <Ntry>
                <Amt Ccy="EUR">259595.60</Amt>
                <CdtDbtInd>CRDT</CdtDbtInd>
                <Sts>BOOK</Sts>
                <BookgDt>
                    <Dt>2008-09-04</Dt>
                </BookgDt>
                <ValDt>
                    <Dt>2008-09-04</Dt>
                </ValDt>
                <AcctSvcrRef>Bankreferenz</AcctSvcrRef>
                <BkTxCd/>
                <NtryDtls>
                    <TxDtls>
                        <AmtDtls>
                            <InstdAmt>
                                <Amt Ccy="USD">360873.97</Amt>
                            ');
INSERT INTO junk_xml (id,nr,fragment)
VALUES (0,8,'</InstdAmt>
                            <TxAmt>
                                <Amt Ccy="EUR">259595.60</Amt>
                            </TxAmt>
                            <CntrValAmt>
                                <Amt Ccy="EUR">259621.56</Amt>
                                <CcyXchg>
                                    <SrcCcy>USD</SrcCcy>
                                    <TrgtCcy>EUR</TrgtCcy>
                                    <XchgRate>1.39</XchgRate>
                                </CcyXchg>
                            </CntrValAmt>
                        </AmtDtls>
                        <BkTxCd>
                            <Prtry>
                                <Cd>NTRF+202</Cd>
                                <Issr>ZKA</Issr>
                            </Prtry>
                        </BkTxCd>
                        <Chrgs>
                            <Amt Ccy="EUR">25.96</Amt>
                        </Chrgs>
                        <RltdPties>
                            <Dbtr>
                                <Nm>West Coast Ltd.</Nm>
                                <PstlAdr>
                                    <Ctry>US</Ctry>
                                    <AdrLine>52, Main Street</AdrLine>
                                    <AdrLine>3733 San Francisco</AdrLine>
                                </PstlAdr>
                            </Dbtr>
                            <DbtrAcct>
                                <Id>
                                    <Othr>
                                        <Id>546237687</Id>
                                    </Othr>
                                </Id>
                            </DbtrAcct>
                        </RltdPties>
                        <RltdAgts>
                            <DbtrAgt>
                                <FinInstnId>
                                    <BIC>BANKUSNY</BIC>
                                </FinInstnId>
                            </DbtrAgt>
                        </RltdAgts>
                        <RmtInf>
                            <Ustrd>Invoice No. 4545</Ustrd>
                        </RmtInf>
                    </TxDtls>
                </NtryDtls>
                <AddtlNtryInf>AZV-UEBERWEISUNGSGUTSCHRIFT</AddtlNtryInf>
            </Ntry>
        </Stmt>
    </BkToCstmrStmt>
</Document>');

COMMIT;

My first idea was to use LISTAGG to splice the pieces, but I get an ORA-01489: result of concatenating string is too long

SELECT  XMLTYPE(
            LISTAGG(fragment,'')
            WITHIN GROUP(ORDER BY nr))
FROM    junk_xml
WHERE   id = 0
GROUP BY id;

I considered also to export the data in another table using perhaps dbms_lob to concatenate the strings, but I'm not allowed to create another table.

No idea how I can access the data hidden in this application?

Concerning

Marcus

P.S.: The application is not on the treatment of the SEPA, but I don't want to show the actual data.

Hi Marcus,

This should work well:

Select xmlparse (document

(xmlcast)

XMLAGG (XMLFOREST (fragment) nr order)

as clob

)

) as complete_doc

of junk_xml

where id = 0;

Tags: Database

Similar Questions

  • Helps the Parseing XML

    Version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

    Hello

    I need assistance with an XML file to generate lines to insert into a table staged for further processing.

    There is an XML document that is loaded into a table in the database via a Web Service call.

    I need to query this table to get the XML code, loop through it to create folders, with the fields in a specific order and insert records into a table of staging.

    There are two columns that are not in the XML that are added during the process. I am including these tables as well.

    I know it is a bunch of "stuff", but I hope I've provided enough information to get help.

    The tables and insert queries:

    -This table contains the XML of the Web Service call

    CREATE TABLE exam_results
    (
    CLOB results_clob
    );

    INSERT INTO exam_results (results_clob)
    VALUES
    ("< result > < candidate > < ProgramCandidateID > 911221 < / ProgramCandidateID > < LastName > V361208 < / LastName > < FirstName > J361208 < / FirstName > < / candidate > < event > < ended > 1 < / filled > < CompleteDate > 2011 - 08 - 05T 10: 23:42.957 < / CompleteDate > < FormName > SSU11-05 < / FormName > < NumStarts > 2 < / NumStarts > < ProgramRegistrationID > SU0006510JV < / ProgramRegistrationID > < result > 564865 identifier < / result identifier >") < Sponsor > MySponsor < / sponsor > < StartTime > 2011 - 08 - 05T 08: 22:47.877 < / StartTime > < TestName > SSU11 < / TestName > < / Event > < start > < Start > < BrowserVersion > 8.0 < / BrowserVersion > < OperatingSystem > Windows NT 4.0 < / OperatingSystem > < / Start > < / begins > < Scores > < issues > < > < name > 105103 < / name > < SeqDelivered > 1 < / SeqDelivered > < response > 1 < / response > < key > 4 < / key > < seconds > 169.126 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261292 < / name > < SeqDelivered > 2 < / SeqDelivered > < answer > 3 < / response > < key > 3 < / key > < seconds > 97.984 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261241 < / name > < SeqDelivered > 3 < / SeqDelivered > < response > 3 < / response > < key > 3 < / key > < seconds > 87.579 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261451 < / name > < SeqDelivered > 4 < / SeqDelivered > < answer > 3 < / response > < key > 3 < / key > < seconds > 59.983 < / seconds (> < Section > 1 < / section > < / Question > < Question > < name > 264373 < / name > < SeqDelivered > 5 < / SeqDelivered > < response > 5 < / response > < key > 1 < / key > < seconds > 86.346 < / seconds > < Section > 1 < / Section > < / Question > < / Questions > < / Scores > < / result > ');

    -This table is to get 1 of the additional columns that must be included

    CREATE TABLE tracking_id_tbl
    (
    tracking_id NUMBER,
    customer_id NUMBER,
    launch_code VARCHAR2 (11)
    );

    INSERT INTO tracking_id_tbl (tracking_id, customer_id, launch_code)

    VALUES (557,2296267, 'SU0006510JV');

    -This table is to get the other extra column which must be included

    CREATE TABLE school_code_tbl
    (
    customer_id NUMBER,
    nb_id NUMBER,
    organization_id VARCHAR2 (8)
    );

    INSERT INTO school_code_tbl (customer_id, nb_id, organization_id)

    VALUES (2296267,911221, '12');

    -This table will receive the file created from the XML

    CREATE TABLE staging_tbl
    (
    results_data VARCHAR2 (4000)
    );

    To facilitate the XML file to read (we hope) here is a formatted version:

    < result >

    < candidate >

    < ProgramCandidateID > 911221 < / ProgramCandidateID >

    < name > V361208 < / LastName >

    J361208 < FirstName > < / name >

    < / candidate >

    < event >

    < finish > 1 < / completed >

    < completeDate > 2011 - 08 - 05T 10: 23:42.957 < / CompleteDate >

    SSU11-05 < FormName > < / FormName >

    < NumStarts > 2 < / NumStarts >

    < ProgramRegistrationID > SU0006510JV < / ProgramRegistrationID >

    ID of < result > 564865 < / ID results >

    < sponsor > MySponsor < / sponsor >

    < StartTime > 2011 - 08 - 05T 08: 22:47.877 < / StartTime >

    SSU11 < TestName > < / TestName >

    < / event >

    < start >

    < start >

    < > 8.0 BrowserVersion < / BrowserVersion >

    < OperatingSystem > Windows NT 4.0 < / OperatingSystem >

    < / start >

    < / starts >

    < scores >

    < questions >

    < question >

    < name > 105103 < / name >

    < SeqDelivered > 1 < / SeqDelivered >

    < response > 1 < / answer >

    < Key > 4 < / key >

    < seconds > 169.126 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 261292 < / name >

    < SeqDelivered > 2 < / SeqDelivered >

    < response > 3 < / answer >

    < Key > 3 < / key >

    < seconds > 97.984 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 261241 < / name >

    < SeqDelivered > 3 < / SeqDelivered >

    < response > 3 < / answer >

    < Key > 3 < / key >

    < seconds > 87.579 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 261451 < / name >

    < SeqDelivered > 4 < / SeqDelivered >

    < response > 3 < / answer >

    < Key > 3 < / key >

    < seconds > 59.983 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 264373 < / name >

    < SeqDelivered > 5 < / SeqDelivered >

    < response > 5 < / answer >

    < Key > 1 < / key >

    < seconds > 86.346 < / seconds >

    article <>1 < / Section >

    < / question >

    < / questions >

    < / scores >

    < / result >

    This XML file is for 1 card. There are several issues that are in the file. I reduced to only 5 is easier to see.

    The layout of the document to be inserted in the staging table is:

    Event.TestName

    Event.FormName

    Event.CompleteDate

    v_tracking_id

    Event.ProgramRegistrationID

    Event.StartTime

    Event.CompleteDate / * end * /.

    Candidate.LastName

    Candidate.FirstName

    Candidate.MiddleName (the middle name does not exist in the file XML then return null)

    Candidate.ProgramCandidateID

    v_school_code

    Candidate.CustomProperties.Answer (this does not exist in the file XML then return null)

    Event.ResultID

    Event.NumStarts

    Event.Completed

    Event.Sponsor

    Scores.Questions.Question.Name

    Scores.Questions.Question.Section

    Scores.Questions.Question.SeqDelivered

    Scores.Questions.Question.Key

    Scores.Questions.Question.Answer

    Scores.Questions.Question.Seconds

    Starts.OperatingSystem

    Starts.BrowserVersion

    The expected output is:

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,105103,1,1,4,1,169.126,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261292,1,2,3,3,97.984,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261241,1,3,3,3,87.579,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261451,1,4,3,3,59.983,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,264373,1,5,1,5,86.346,Windows NT 4.0,8.0");

    The Questions/Question, is what makes a separate line if the values for the other fields would be the same for however many questions is in the XML file.

    That's what I've tried so far:

    DECLARE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             CURSOR get_results_cur
    IS
    SELECT results_clob
    Of exam_results;

    get_results_rec XMLTYPE.
    get_results_clob CLOB.
    NUMBER (38) v_count: = 1;


    v_result VARCHAR2 (32000);
    v_tracking_id tracking_id.tracking_id_tbl%TYPE;
    v_school_code organization_id.school_code_tbl%TYPE;

    BEGIN
    OPEN get_results_cur.
    SEEK get_results_cur INTO get_results_clob;
    CLOSE Get_results_cur;

    get_results_rec: = xmltype.createxml (get_results_clob);

    SELECT tracking_id
    school_code
    IN v_tracking_id
    v_school_code
    OF ti tracking_id_tbl
    JOIN school_code_tbl ON ti.customer_id = sc.customer_id sc
    WHERE ti.launch_code = get_results_rec. EXTRACT ('/ Result/Event/ProgramRegistrationID/text()').getstringval () AND)
    nb_id = get_results_rec. EXTRACT ('/ Result/Candidate/ProgramCandidateID/text()').getstringval ();)

    While get_results_rec. EXISTSNODE ('/ / result [' | v_count |]) ']') = 1
    LOOP
    v_result: =.
    (get_results_rec. EXTRACT ('/ results/event/TestName [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/FormName [' | v_count | / text () ']) .getstringval ())
    || ','
    || ((get_results_rec. EXTRAIT ('/ résultats/événement/CompleteDate [' || v_count || / text () SUBSTR']) .getstringval ()), 1, 10)
    || ','
    || v_tracking_id
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/ProgramRegistrationID [' | v_count | / text () ']) .getstringval ())
    || ','
    || ((get_results_rec. EXTRAIT ('/ résultats/événement/StartTime [' || v_count || / text () SUBSTR']) .getstringval ()), 12.8)
    || ','
    || ((get_results_rec. EXTRAIT ('/ résultats/événement/CompleteDate [' || v_count || / text () SUBSTR']) .getstringval ()), 12.8)
    || ','
    || (get_results_rec. EXTRACT ('/ result/candidate/name [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ result/candidate/name [' | v_count | / text () ']) .getstringval ())
    || ',,'
    || -(get_results_rec. Extract('/result/candidate/MiddleName [' || v_count ||) '] / text () ') .getStringVal ()); ',' ||
    (get_results_rec. EXTRACT ('/ result/candidate/ProgramCandidateID [' | v_count | / text () ']) .getstringval ())
    || ','
    || v_school_code
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/result identifier [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/NumStarts [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/completed [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/sponsor [' | v_count | / text () ']) .getstringval ());
    || ','

    -Add the results of the first question

    || ','
    || (get_results_rec. EXTRACT ('/ result, departures, Start, OperatingSystem [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ result, departures, Start, BrowserVersion [' | v_count | / text () ']) .getstringval ());

    v_count: = v_count + 1;

    INSERT INTO staging_tbl (results_data)
    VALUES (v_result);

    END LOOP;
    END;

    What can clear?

    Thank you

    Joe

    You have several questions in the XML, so when flattened document you will have several lines trying to extract in v_result.  Where the error.  You will need to either loop

    for rec in (select... from XMLTable...)

    loop

    insert into staging_tbl...

    end loop;

    or make an insert select

    insert into staging_tbl (results_data)

    Select...

    from XMLTable...

  • Problem copying 4000 characters of CLOB in VARCHAR2 (4000 TANK)

    I'm migrating data from a table where it is stored in a CLOB to another table where I said a column of VARCHAR2(4000 CHAR).

    I stated a cursor in the form:

    (a) select columna, columnb, substr(clob_column,1,4000) of...

    (b) select columna, columnb, dbms_lob.substr(clob_column,4000,1) of...

    I then loop and EXTRACT the value of substr in a variable that is declared as VARCHAR2 (4000 TANK)

    With the cursor version 'a', using the regular subtr function, I get: ORA-01461: can bind to a LONG value only for insert into a LONG column

    With the slider 'b' version, by using the dbms_lob.substr function, I get: ORA-06502: PL/SQL: digital or value error: character string buffer too small

    I use Oracle 10.2.0.4.0

    I don't know yet what to watch next?

    Machinery says:

    However, the database uses NLS_CHARACTERSET UTF8 and NLS_NCHAR_CHARACTERSET = AL16UTF16, which are multibyte so I was expecting the declared with semantic CHAR VARCHAR2 to be multibyte.

    And it is. But in Oracle SQL VARCHAR2, as I already mentioned, must not exceed 4000 bytes. So even if you have declared it as 4000 characters, you'll get an error when the total length in bytes is greater than 4000. And since, according to the character set, a character can be 1 to 4 bytes, Oracle takes the best cases and allows you to declare it as max 4000 characters. How many characters will fit in eseccion is another question.

    SY.

  • Err: ORA-31011: failed to parse XML

    Hello

    While inserting the XML code in the table, I faced slot problem, Pls suggest a way out of the code.
    Your help is appreciate.
    I'm using the version of Oracle - 10.2.0.2.0

    Err: ORA-31011: failed to parse XML
    ORA-19202: an error has occurred in the processing of XML
    LPX-00234: the 'xsi' namespace prefix is not declared
    Error on line 1
    ORA-06512: at "SYS." XMLTYPE", line 254
    ORA-06512: at line 1

    -Step 1
    CREATE TABLE EMP (EMPCODE NUMBER (8), EMPNAME VARCHAR2 (100), THE NUMBER OF EMPDEPTNO (8), NUMBER EMPSAL (34.2));
    /
    -Step 2
    BEGIN
    FOR X IN (SELECT * FROM USER_OBJECTS S WHERE ROWNUM < = 50)
    LOOP
    INSERT INTO VALUES EMP (X.OBJECT_ID, X.OBJECT_NAME, 20, X.OBJECT_ID + 10);
    END LOOP;
    COMMIT;
    END;
    /
    -Step 3
    create the table EMPXML (XMLCLOB XMLTYPE);
    /
    -Step 4
    DECLARE
    v_xmldata CLOB.
    v_tmpdata CLOB.
    v_xmltype XMLTYPE.
    BEGIN
    DBMS_LOB.CREATETEMPORARY (v_tmpdata, false);
    v_xmldata: = ' <? XML version = "1.0" encoding = "UTF-8"? > ';

    SELECT Xmlelement ("employee",

    XmlAttributes ("http://ns.oracle.com.tw/XSD/ORACLE/ESB/Message/EMF/ServiceEnvelope" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" AS ")
    "xmlns:ns0,"
    ' http://ns.oracle.com.tw/XSD/ORACLE/ESB/Message/EMF/ServiceEnvelope ServiceEnvelope.xsd > ' AS
    ("xsi: schemaLocation").
    XMLAGG (Xmlforest (AS Empcode "EmpID",
    EmpName AS "EmpName",.
    Empsal AS 'EmpSal'))) BY v_xmltype
    FROM Emp
    WHERE Empdeptno = 20;

    SELECT v_xmltype.getCLOBVal () IN the v_tmpdata FROM dual;

    DBMS_LOB. Append (v_xmldata, v_tmpdata);

    BEGIN
    INSERT IN EMPXML VALUES (xmltype (v_xmldata));
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line ('Err: ' |) SQLERRM);
    END;
    END;
    /
    -Step 5
    SELECT * from empxml;
    /
    -Step 6
    DROP TABLE EMP PURGE;
    /
    -Step 7
    DROP TABLE EMPXML PURGE;
    /
    Thank you and best regards,
    Yogesh Nagle
    India

    What? Pepijn you provided the correct use of Xmlattributes and showed that your script would go without errors. What is the problem with his answer or it does not that you need it?

  • Problem in parsing XML

    Hello

    Any1 can you please tell me how to do Xml parsing in Blackberry. I'm a bit confused by it.

    Assume that it is my link:

    {keyword: "keword", url: "videoUrl"}

    While parsing xml:

    String keyword1 ="";

    element.getName.equalsIgnoreCase ("keyword");

    keyword1 = Element.GetText ();

    is she writing?

    Hey its done.

  • Parsing XML and get the attributes of a tag

    Hello

    When parsing XML for application of Cascades in C++, I am able to get the value of a tag as follows:

    00000

    But I also want to get the attributes of a tag:

    But I don't know how to get the 'CA' and 'California' attributes with my current code.  Can anyone help?  Here is the code I use to parse the XML code:

    void CMController::requestFinished(QNetworkReply* reply) {
    
        if (reply->error() == QNetworkReply::NoError) {
    
            QXmlStreamReader xml;
    
            QByteArray data = reply->readAll();
            xml.addData(data);
    
            QString zip;
            QString id;
            QString location;
    
            while (!xml.atEnd() && !xml.hasError()) {
    
                /* Read next element.*/
                QXmlStreamReader::TokenType token = xml.readNext();
    
                /* If token is just StartDocument, we'll go to next.*/
                if (token == QXmlStreamReader::StartDocument) {
                    continue;
                }
    
                /* If token is StartElement, we'll see if we can read it.*/
                if (token == QXmlStreamReader::StartElement) {
    
                    if (xml.name() == "zip") {
                        zip = xml.readElementText();
                    }
    
                    if (xml.name() == "id") {
                        ???
                    }
    
                    if (xml.name() == "location") {
                        ???
                    }
    
                }
    
            }
    
            emit succeeded(result);
    
        } else {
            emit failed();
        }
    
        reply->deleteLater();
    
    }
    

    Thank you!

    I found a working example:

    if(xml.name() == "state"){
        QXmlStreamAttributes attrib = xml.attributes();
        QStringRef ref = attrib.value("location");
        qDebug() << "location: " << ref;
    }
    
  • Widget to the Web service, parsing XML

    I worked on the communication with my web services and back to my widget.

    By using the code below, I was able to perform a GET and repay the XML, but I can't find data where I expect it to be node-wise when parsing XML. I return an object with 3 variables attached to it. I expect to be child nodes 1, 2, and 3. They proved to be 1, 3 and 5 nodes.

    Any ideas on why or how? I feel I'm missing just a simple thing in all of this.

    XML response

    
    - http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
      1000
      Test Station
      105.285
      
    

    The widget code

    //****************** Ajax Logic ******************
    var xmlHttp;
    function getStationUpdate() {
    
        alert("in station update");
        xmlHttp = new XMLHttpRequest();
    
        var Posturl = "http://MachineIPGoesHERE:51107/Service1.asmx/HelloWorld2?";
        alert("after post url");
        xmlHttp.onreadystatechange = updateData;
        alert("after onReadyStateChange");
        xmlHttp.open("GET", Posturl, true);
        alert("after GET");
    
        xmlHttp.send(null);
    }
    
    function updateData() {
        if (xmlHttp.readyState == 4) {
            alert(xmlHttp.responseText);
            parser = new DOMParser();
            var xmlDoc = parser.parseFromString(xmlHttp.responseText, "text/xml");
    
            alert(xmlDoc.documentElement.childNodes[1].tagName + " " + xmlDoc.documentElement.childNodes[1].childNodes[0].nodeValue);
            //alert(xmlDoc.documentElement.childNodes[1].childNodes.length);
            //alert(xmlDoc.documentElement.childNodes[1].hasChildNodes());
            //alert(xmlDoc.documentElement.childNodes[2].hasChildNodes());
            //alert(xmlDoc.documentElement.childNodes[2].tagName + " " + xmlDoc.documentElement.childNodes[2].childNodes[0].nodeValue);
            alert(xmlDoc.documentElement.childNodes[3].tagName + " " + xmlDoc.documentElement.childNodes[3].childNodes[0].nodeValue);
            alert(xmlDoc.documentElement.childNodes[5].tagName + " " + xmlDoc.documentElement.childNodes[5].childNodes[0].nodeValue);
    
            alert(xmlDoc.documentElement.childNodes.length);
        }
    

    Web service

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Xml.Serialization;
    
    namespace WebService1
    {
        /// 
        /// Summary description for Service1
        /// 
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
         [System.Web.Script.Services.ScriptService]
        public class Service1 : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
    
            [WebMethod]
            public myTestObj HelloWorld2()
            {
                myTestObj test = new myTestObj();
                return test;
            }
        }
    
        [Serializable]
        public class myTestObj
        {
            private int _StationID;
            private string _StationName;
            private double _Volume;
    
            [XmlElementAttribute(Order = 0)]
            public int StationID
            {
                get
                {
                    return this._StationID;
                }
                set
                {
                    this._StationID = value;
                }
            }
    
            [XmlElementAttribute(Order = 1)]
            public string StationName
            {
                get
                {
                    return this._StationName;
                }
                set
                {
                    this._StationName = value;
                }
            }
    
            [XmlElementAttribute(Order = 2)]
            public double Volume
            {
                get
                {
                    return this._Volume;
                }
                set
                {
                    this._Volume = value;
                }
            }
    
            public myTestObj()
            {
                StationID = 1000;
                StationName = "Test Station";
                Volume = 105.285;
            }
        }
    }
    

    > Any ideas on why or how? I feel I'm missing just a simple thing in all of this.

    White space nodes?

  • string aggregation &gt; 4000 store in varchar2 (4000)

    Dear experts,

    I'm using Oracle 11.2.0.3. I have the table such as

    ID NAME

    1 xyz

    1 abc xyz

    1 xyz abc def

    2 abc

    2 xyz nmnx

    I want to aggregate them so that I have the aggregation of the NAME by ID

    as

    1XYZ xyz abc xyz abc def
    2ABC xyz nmnx

    I was able to do this using:

    WITH t
         AS (SELECT 1 AS id, 'xyz' AS name FROM DUAL
             UNION ALL
             SELECT 1, ' xyz abc' FROM DUAL
             UNION ALL
             SELECT 1, 'xyz abc  def' FROM DUAL
             UNION ALL
             SELECT 2, 'abc' FROM DUAL
             UNION ALL
             SELECT 2, 'xyz  nmnx' FROM DUAL)
    SELECT     id, RTRIM (XMLCAST (XMLAGG (XMLELEMENT (e, name, ' ') ORDER BY NULL) AS CLOB)) as agg_name
        FROM   t
    GROUP BY   id;
    
    

    However, if the length (agg_name) > 8 (for simplicity), then the name should be on a separate line with the same id

    1 xyz xyz

    1 abc def

    1 xyz ABC

    2 abc xyz

    2 nmnx

    token order is not important.

    Thanks for any help

    Above could be done using

    WITH t
         AS (SELECT 1 AS id, 'xyz' AS name FROM DUAL
             UNION ALL
             SELECT 1, ' xyz abc' FROM DUAL
             UNION ALL
             SELECT 1, 'xyz abc  def' FROM DUAL
             UNION ALL
             SELECT 2, 'abc' FROM DUAL
             UNION ALL
             SELECT 2, 'xyz  nmnx' FROM DUAL)
    SELECT     ID, LISTAGG (name) WITHIN GROUP (ORDER BY NULL) org_name
        FROM   (SELECT   ID,
                         name || ' ' name,
                         CEIL (SUM (len) OVER (PARTITION BY ID ORDER BY len) / 8) part,
                         len
                  FROM   (SELECT    /*distinct */  ID, x.name, LENGTH (x.name || ' ') len
                             FROM   t, XMLTABLE ('ora:tokenize(.," ")' PASSING ' ' || TRIM (name) COLUMNS name VARCHAR2 (4000) PATH '.') x
                            WHERE   x.name IS NOT NULL))
    GROUP BY   ID, part;
    
  • Best way to Parse XML using Dreamweaver CC 2015.3

    I was on a wild goose chase - trying to figure out how to parse XML using DW CC

    every article I read, says something about XML & XSLT, but it is no longer available in the new CC - I read about using jQuery or php, but have not yet find a resource to learn specifically "using DW CC.

    I'm willing to learn how to parse XML with DW CC but I would get a definitive direction to go before I'm trying to learn something that adobe will put in 'end of life '.

    advice or links to resources that can parse XML DW CC 2015 would be LARGELY APPRECIATED, thank you

    x 126 has written:

    What I'm asking is...

    1. What is the best procedure to insert XML into a page using DW CC 2015 as my editor?
    a. what happened to spry? b. what happened to XSLT?

    As Nancy explained, Spry has been abandoned by Adobe, a few years ago.

    XSLT server behavior has been removed at the same time as other server behaviors Dreamweaver CC. The problem with most of the PHP server behaviors was that they were based on code that has been removed from PHP 7. The XSLT server behavior didn't rely on these features, but it was not the most friendly of server behaviors. XSLT is a complex language that is to be avoided when parsing XML unless you really know what you're doing.

    The easiest way to manipulate XML in Dreamweaver should use PHP SimpleXML. I've linked to the samples page in the PHP online documentation. Believe me, it's much easier than trying to do battle with XSLT. If you have a subscription to lynda.com, you can learn more about SimpleXML to my operational with SimpleXMLclass.

  • VARCHAR2 (4000 tank) in AL32UTF8

    Hello

    I have an instance using AL32UTF8. There is a column in a table is defined as VARCHAR2 (4000 tank). I can fill a string with 4,000 characters (multi-byte language) to this column?

    Thank you

    >
    that means that the length of VARCHAR maxiumn is 4000 BYTES, regardless of the configuration?
    >
    Yes - the maximum length of VARCHAR2 is 4000 bytes.

    Oracle allows to specify VARCHAR2 (4000 TANK) for a base of multibyte character set, since it is legal to insert 4000 single-byte characters. But it is to make sure that you don't try to integrate more than 4000 bytes.

  • Parsing XML in ColdFusion 5

    Hello there,

    It's not like there is a native way to parse XML in ColdFusion version 5.0. ColdFusion MX makes it easier to work with XML, but unfortunately I am working under Windows with a CF5 server.

    I've gotten to the point of use CFHTTP to retrieve XML content in a variable, but I don't know the best way to decompress the data in a query, or another structure that I can use to feed the rest of the model. I thought to save the content of a file and then a loop top, but something tells me that it is an inefficient way to do the job.

    I would like to avoid having to install any additional software, but if it's the only way to process XML in CF5, then I would be grateful for any recommendations on the best tools to evaluate or buy. Or if there is a way to do it in JavaScript, it would be great, too.

    Thanks for any help!

    try to use SoXML, it is a custom tag, is free and can be downloaded from the Adobe Exchange website

    --> Adobe Exchange link

    M

  • Remove the specific node of an XML stored as XMLType

    Hello

    I have a XML stored as XMLType,

    < ocaStatus xmlns = "http://xmlbeans.apache.org/ocastatus" >
    < status >
    < > 700 statusCode < / statusCode >
    < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate >
    < username > 1234 < / userId >
    < comment > Document is deleted from the OCA. < / comment >
    < / status >
    < status >
    < > 934 statusCode < / statusCode >
    < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate >
    < username > 1234 < / userId >
    < comment > Document is deleted from the OCA. < / comment >
    < / status >
    < status >
    < > 934 statusCode < / statusCode >
    < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate >
    < username > 1234 < / userId >
    < comment > Document is deleted from the OCA. < / comment >
    < / status >
    < / ocaStatus >

    I have a requirement where the first occurrence of statusCode 934 should be removed from the XML.
    I can do through a java program. But that is costly.
    Is there a way that this can be done by a SQL XMLQuery/XPath statement?

    Help, please.
    Thanks in advance.

    You can use DELETEXML:

    SQL> select xml from myxml;
    
    XML
    --------------------------------------------------------------------------------
    
    
    700
    2010-03-31 12:39:41.580 GMT+05:30
    1234
    Document is deleted from OCA.
    
    
    934
    2010-03-31 12:39:41.580 GMT+05:30
    1234
    Document is deleted from OCA.
    
    
    934
    2010-03-31 12:39:41.580 GMT+05:30
    1234
    Document is deleted from OCA.
    
    
    
    SQL> update myxml
      2  set xml = deletexml(xml,'//status[statusCode="934"][1]',
      3                          'xmlns="http://xmlbeans.apache.org/ocastatus"');
    
    1 row updated.
    
    SQL> select xml from myxml;
    
    XML
    --------------------------------------------------------------------------------
    
    
    700
    2010-03-31 12:39:41.580 GMT+05:30
    1234
    Document is deleted from OCA.
    
    
    934
    2010-03-31 12:39:41.580 GMT+05:30
    1234
    Document is deleted from OCA.
    
    
    

    Max
    http://oracleitalia.WordPress.com

  • VARCHAR2 (4000) - absolute max?

    I have the following code to create a table using sqlplus.

    create table psncatsdw.acc_narrative)
    accident_num varchar2 (20).
    agency_code varchar2 (6).
    number of accident_rec_num
    VARCHAR2 (4000) narrative.
    date of input_date_time
    );


    The size in bytes max for a varchar2 is 4000. Is it possible to increase it? The "narrative" field is a field where a user basically gives his version of an accident. Recently we had a problem with that. Has never exceeded the 4000 bytes max. Some people take longer than others :) The input tool, that users have is no limit put in place to force it to keep under 4000 (and is not really practical for me to get that changed). So, when I try to load the table with data from all users, almost all of the load will fail when it reaches a 'story' longer than 4000 bytes. When I try to change the size in bytes max on the table I get predictable one error "ORA-00910: specified length too long for its data type. Is there a way hidden for me to get around this size in bytes max?


    Thank you!

    Hello

    Yes, there are way to increase it, use CLOB data type

    create table psncatsdw.acc_narrative(
    accident_num varchar2(20),
    agency_code varchar2(6),
    accident_rec_num number,
    narrative clob default empty_clob(),
    input_date_time date
    );
    

    Concerning

  • Parsing xml and store the details in the hierarchical tables

    Hi all

    I'm trying to parse a xml code and store the details in the hierarchical tables, however, I am unable to analyze the child attributes of tags and store the details in relational format.

    Oracle - 11.2.0.4 version

    My XML looks like in below:

    <Root>
    <ParentTag name="JobName" attrib1="Text" attrib2="SomeOtherText">
      <ChildTag childAttrib1="SomeValue1" childAttrib2="SomeValue2" />
      <ChildTag childAttrib1="SomeValue3" childAttrib2="SomeValue4" />
      <ChildTag childAttrib1="SomeValue5" childAttrib2="SomeValue6" />
    
      <OtherChildTag childAttrib1="SomeValue1" childAttrib2="SomeValue2" />
    </ParentTag>
    </Root>
    
    

    The table structure is as follows:

    create the table parent_details
    (
    job_id number primary key,
    VARCHAR2 (100) job_name,.
    job_attrib1 varchar2 (100),
    job_attrib2 varchar2 (100)
    );

    create the table child_details
    (
    child_id number primary key,
    number of parent_job_id
    child_attrib1 varchar2 (100),
    child_attrib2 varchar2 (100),
    Constraint fk_child_details foreign key (parent_job_id) refers to parent_details (job_id)
    );

    After analysis, I would expect the data to be stored in the format below:

    Table Name:-
    parent_details
    ID Name     Attribute1  Attribute2
    1  JobName  Text        SomeOtherText
    
    
    ChildTable (Store Child Tag details)
    ID Parent ID Attribute1  Attribute2
    1  1         SomeValue1  SomeValue2
    2  1         SomeValue3  SomeValue4
    3  1         SomeValue5  SomeValue6
    
    

    I tried following SQL, but it does not work. Please suggest if the same SQL can be improved to get the details in the expected format or should I use another solution.

    select job_details.*
      from test_xml_table t,
           xmltable ('/Root/ParentTag'
                      passing t.col 
                      columns 
                        job_name varchar2(2000) path '@name',
                        attribute1 varchar2(2000) path '@attrib1',
                        attribute2 varchar2(2000) path '@attrib2',
                        childAttribute1 varchar2(2000) path '/ChildTag/@childAttrib1'
                    ) job_details;
    

    I'm not forced to have a SQL solution, but would if it can be in SQL.

    Kind regards

    Laureline.

    Post edited by: Jen K - added the SQL, I tried to build.

    Well, the XML contains hierarchical data, and SQL is a "dish" of data, so it's up to you to treat lines that are coming out of the flat style and determine how to get that in separate tables.

    Suppose that we have several nodes of ParentTag each containing several nodes of ChildTag...

    SQL > ed
    A written file afiedt.buf

    1 with t (xml) as (select xmltype ('))
    2
    3
    4
    5
    6
    7

    8
    9
    10
    11
    12

    13
    ') of double)
    14-
    15 end of test data
    16-
    17 select x.p
    18, x.name, x.attrib1, x.attrib2
    19, including
    20, y.childattrib1, y.childattrib2
    21 t
    22, xmltable ('/ Root/ParentTag ')
    23 passage t.xml
    p 24 columns for ordinalite
    25, path name varchar2 (10) '. / @name'
    26, path of varchar2 (10) of attrib1 '. / @attrib1 '


    27, way to varchar2 (10) of attrib2 '. / @attrib2 '
    28 children xmltype road '.'
    29                 ) x
    30, xmltable ('/ ParentTag/ChildTag ')
    passage 31 x.children
    c 32 columns for ordinalite
    33, path of varchar2 (10) of childattrib1 '. / @childAttrib1 '
    34 road of varchar2 (10) of childattrib2 '. / @childAttrib2 '
    35*                ) y
    SQL > /.

    P NAME ATTRIB1 ATTRIB2 C CHILDATTRI CHILDATTRI
    ---------- ---------- ---------- ---------- ---------- ---------- ----------
    1 text JobName SomeOtherT 1 SomeValue1 value2
    1 text JobName SomeOtherT 2 SomeValue3 SomeValue4
    1 text JobName SomeOtherT 3 SomeValue5 SomeValue6
    JobName2 TextX SomeOtherT 1 SomeValue6 SomeValue8 2
    JobName2 TextX SomeOtherT 2 SomeValue7 SomeValue9 2

    Using the 'ordinalite' gives us the line number for this node in the XML file, so that you can identify each parent as well as to say who is the first record of this parent (because it will have a child with the ordinalite 1).

    An INSERT ALL tuition assistance we can insert into two different tables at the same time to keep related data... for example

    SQL > create table tbl1 (pk number, name varchar2 (10), attrib1 varchar2 (10), attrib2 varchar2 (10))
    2.

    Table created.

    SQL > create table tbl2 (parent_pk number, attrib1 varchar2 (10), attrib2 varchar2 (10))
    2.

    Table created.

    SQL > insert all
    2 when c = 1 then
    3 in the tbl1 (pk, attrib1, attrib2)
    4 values (p, attrib1, attrib2)
    When 5 1 = 1 then
    6 in the tbl2 (parent_pk, attrib1, attrib2)
    7 values (p, childattrib1, childattrib2)
    8 with t (xml) as (select xmltype ('))
    9
    10
    11
    12
    13
    14

    15
    16
    17
    18
    19

    20
    ') of double)
    21 select x.p
    22, x.name, x.attrib1, x.attrib2
    23, including
    24, y.childattrib1, y.childattrib2
    25 t
    26, xmltable ('/ Root/ParentTag ')
    27 passage t.xml
    p 28 columns for ordinalite
    29, path name varchar2 (10) '. / @name'
    30, path of varchar2 (10) of attrib1 '. / @attrib1 '
    31, path of varchar2 (10) of attrib2 '. / @attrib2 '
    32 children xmltype road '.'
    33                 ) x
    34, xmltable ('/ ParentTag/ChildTag ')
    passage 35 x.children
    c 36 columns for ordinalite
    37, path of varchar2 (10) of childattrib1 '. / @childAttrib1 '
    38, path of varchar2 (10) of childattrib2 '. / @childAttrib2 '
    39                 ) y
    40.

    7 lines were created.

    SQL > select * from tbl1;

    PK ATTRIB1 ATTRIB2 NAME
    ---------- ---------- ---------- ----------
    1 text JobName SomeOtherT
    2 JobName2 TextX SomeOtherT

    SQL > select * from tbl2.

    PARENT_PK ATTRIB1 ATTRIB2
    ---------- ---------- ----------
    1 SomeValue1 value2
    1 SomeValue3 SomeValue4
    1 SomeValue5 SomeValue6
    SomeValue6 2 SomeValue8
    SomeValue7 2 SomeValue9

  • Parse XML and insert into the table Oracel

    Hi all

    I have an XML document, I need to analyze and take the respective tag data and inserting it into another table.

    This is the XML code that I have.

    " < convertTo xsi: schemaLocation =" https://xecdapi.XE.com/schema/v1/convertTo.xsd "> "

    < terms > http://www.XE.com/privacy.php < / terms >

    < privacy > http://www.XE.com/legal/DFS.php < / privacy >

    < to > < /pour > USD

    < amount > 1.0 < / amount >

    < timestamp > 2015-10-25T 23: 00:00Z < / timestamp >

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo >


    Here is the code I use to analyze the values

    DECLARE

    XMLType x: = XMLType)

    ' ' < convertTo xsi: schemaLocation = " https://xecdapi.XE.com/schema/v1/convertTo.xsd "> "

    < terms > http://www.XE.com/privacy.php < / terms >

    < privacy > http://www.XE.com/legal/DFS.php < / privacy >

    < to > < /pour > USD

    < amount > 1.0 < / amount >

    < timestamp > 2015-10-25T 23: 00:00Z < / timestamp >

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo > '

    );

    BEGIN

    FOR r IN

    (

    SELECT

    Name of the AS ExtractValue (Value (p),'/ rate/currency/text () ')

    -, ExtractValue (value (p), '/ Row/Address/State/Text ()') State

    -, ExtractValue (value (p), '/ Row/Address/City/Text ()') city

    Of

    TABLE (XMLSequence (Extract(x,'convertTo/from/rate'))) p

    )

    LOOP

    -do what you want with r.name, r.state, r.city

    dbms_output.put_line ('Name' | r.Name);

    END LOOP;

    END;

    I get the error message below

    Error report:

    ORA-31011: XML parsing failed

    ORA-19202: an error has occurred in the processing of XML

    LPX-00234: the 'xsi' namespace prefix is not declared

    Error on line 1

    ORA-06512: at "SYS." XMLTYPE", line 310

    ORA-06512: at line 2

    31011 00000 - "XML parsing failed"

    * Cause: XML parser returned an error trying to parse the document.

    * Action: Check whether the document to parse is valid.

    Any help on how to fix this would be really useful.

    Appreciate your time and your help.

    Thank you

    Olivier

    Have you even tried to do what we have suggested?

    SQL > ed
    A written file afiedt.buf

    1 with t as (select xmltype ('))
    "" 2 http://xecdapi.xe.com "xmlns: xsi ="http://www.w3.org/2001/XMLSchema-instance"" xsi: schemaLocation = "https://xecdapi.xe.com/schema/v1/convertTo.xsd" > ""
    3 http://www.xe.com/privacy.php
    4 http://www.xe.com/legal/dfs.php
    5 USD
    6    1.0
    7 2015-10 - 25 T 23: 00:00Z
    8
    9
    10 EUROS
    11 0.9075541422
    12

    13

    14
    ") in XML of the double)"
    15-
    16 end of test data
    17-
    18 select x.*
    19 t
    20, xmltable (xmlnamespaces ("http://www.w3.org/2001/XMLSchema-instance" as "xsi", default 'http://xecdapi.xe.com'),)
    21 ' / convertTo/of/rate.
    22 passage t.xml
    path of VARCHAR2 (3) currency 23 columns '. / currency '
    24, half-way number '. / mid'
    25*                ) x
    SQL > /.
    HEART MI
    --- ----------
    EUR.907554142

    1 selected line.

Maybe you are looking for

  • MY iphone6 will not return from the icloud, HELP?

    I had to replace my phone.  The new phone will not render from the icloud.  I tried several times and I even took it in the Apple store without success.

  • HP ENVY 17-j070ca Notebook PC: how to find palmcheck option?

    I have problem with finding palmcheck.i went to the mouse settings and parameters clickpad as well, but it has been not.can sombody tell me whats going on?

  • Windows 7 stuck on blue screen

    Windows 7 pro Start pc makes me blue screen F8 options makes me blue screen Recovery dell boot on USB makes me fancy blue screen with poorly seen face

  • Switch to blackBerry Smartphones AT &amp; T - No. BBM or email

    Hello Just moved to the States and has more than my blackberry of Rogers Wireless. I now have a map of AT & T and the SIM works for phone, internet and text, but does not work for BBM or email. All solutions? I have tried a soft reboot but no luck. T

  • error applyPreset

    HelloI have a script UI Palette. Adds a preset to a null value of the controller using applyPreset ffx. It also adds different expression of different properties on a layer. So that this layer is now controlled by the null value of the controller.It