Retrieve XML stored in CLOB as columns

Hi,
I have the below table that holds XML in a CLOB
CREATE TABLE testxml
  (idcol NUMBER(3), xml_data CLOB
INSERT
INTO testxml VALUES
    201,
<TRADE>
   <TRADETYPE>SWAP</TRADETYPE>
   <SUBTYPE>CDS</SUBTYPE>
   <TRADEHEADER>
      <ACTION>NEW</ACTION>
      <SOURCEID>ABS-CD</SOURCEID>
      <TRADEID>20595896</TRADEID>
   </TRADEHEADER>
   <TRADELEGS>
      <TRADELEG>
         <PAY_OR_RECEIVE>P</PAY_OR_RECEIVE>
         <FIXED_FLOAT_IND>FLT</FIXED_FLOAT_IND>
         <DAY_COUNT_BASIS>A365F</DAY_COUNT_BASIS>
         <ORIG_PRIMARY_CURRENCY>ZAR</ORIG_PRIMARY_CURRENCY>
         <FIRST_VALUE_DATE>20120511</FIRST_VALUE_DATE>
      </TRADELEG>
      <TRADELEG>
         <PAY_OR_RECEIVE>R</PAY_OR_RECEIVE>
         <FIXED_FLOAT_IND>FIX</FIXED_FLOAT_IND>
         <DAY_COUNT_BASIS>A365F</DAY_COUNT_BASIS>
         <ORIG_PRIMARY_CURRENCY>ZAR</ORIG_PRIMARY_CURRENCY>
         <FIRST_VALUE_DATE>20120511</FIRST_VALUE_DATE>
      </TRADELEG>
   </TRADELEGS>
   <PVS>
      <PV_SOURCE>ABS-CD</PV_SOURCE>
      <PV>
         <NPV>0</NPV>
         <NPV_CCY>ZAR</NPV_CCY>
         <VALUATION_DATE>20130628</VALUATION_DATE>
         <LEG_NUMBER>1</LEG_NUMBER>
      </PV>
      <PV>
         <NPV>2214864.54</NPV>
         <NPV_CCY>ZAR</NPV_CCY>
         <VALUATION_DATE>20130628</VALUATION_DATE>
         <LEG_NUMBER>2</LEG_NUMBER>
      </PV>
   </PVS>
   <CREDIT_DERIVATIVES>
      <CREDIT_DERIVATIVE>
         <NOMINAL>100000000</NOMINAL>
         <MATURITY_DATE>20170620</MATURITY_DATE>
         <BUY_SELL_INDICATOR>SELL</BUY_SELL_INDICATOR>
         <CURRENCY>ZAR</CURRENCY>
      </CREDIT_DERIVATIVE>
      <CREDIT_DERIVATIVE>
         <NOMINAL>100002000</NOMINAL>
         <MATURITY_DATE>20170620</MATURITY_DATE>
         <BUY_SELL_INDICATOR>BUY</BUY_SELL_INDICATOR>
         <CURRENCY>USD</CURRENCY>
      </CREDIT_DERIVATIVE>
   </CREDIT_DERIVATIVES>
</TRADE>
I need the data to be retrieved as columns. I have tried the below SQL but it works for one XMLTable i.e. TRADELEGS. But If I try to use another XMLTable for PVS then it does a cartesian join.
SELECT id,
  xmltype(xml_data).extract('/TRADE/TRADETYPE/text()').getStringVal()          AS TRADETYPE,
  xmltype(xml_data).extract('/TRADE/SUBTYPE/text()').getStringVal()            AS SUBTYPE,
  xmltype(xml_data).extract('/TRADE/TRADEHEADER/ACTION/text()').getStringVal() AS ACTION,
  x.PAY_OR_RECEIVE,
  x.FIXED_FLOAT_IND
FROM testxml,
  XMLTable( '/TRADE/TRADELEGS/TRADELEG' passing XMLTYPE(xml_data)
  columns
  PAY_OR_RECEIVE VARCHAR2(20) PATH 'PAY_OR_RECEIVE'
  , FIXED_FLOAT_IND VARCHAR2(20) PATH 'FIXED_FLOAT_IND' ) x;
The below query does not work:
SELECT id,
  xmltype(xml_data).extract('/TRADE/TRADETYPE/text()').getStringVal()          AS TRADETYPE,
  xmltype(xml_data).extract('/TRADE/SUBTYPE/text()').getStringVal()            AS SUBTYPE,
  xmltype(xml_data).extract('/TRADE/TRADEHEADER/ACTION/text()').getStringVal() AS ACTION,
  tradeleg.PAY_OR_RECEIVE,
  tradeleg.FIXED_FLOAT_IND
  ,xmltype(xml_data).extract('/TRADE/PVS/PV_SOURCE/text()').getStringVal() AS PV_SOURCE
  ,pvs.npv,
  pvs.VALUATION_DATE
FROM testxml,
  XMLTable( '/TRADE/TRADELEGS/TRADELEG' passing XMLTYPE(xml_data)
  columns
  PAY_OR_RECEIVE VARCHAR2(1) PATH 'PAY_OR_RECEIVE'
, FIXED_FLOAT_IND VARCHAR2(3) PATH 'FIXED_FLOAT_IND' ) tradeleg
  ,XMLTable( '/TRADE/PVS/PV' passing XMLTYPE(xml_data)
  columns
  NPV NUMBER PATH 'NPV'
, VALUATION_DATE VARCHAR2(8) PATH 'VALUATION_DATE' ) pvs
WHERE id = 1;
I need the output for TRADELEGS, PVS and CREDIT_DERIVATIVES.
Regards,
Vikram

But If I try to use another XMLTable for PVS then it does a cartesian join.
Of course it does. You have to use a join condition of some kind.
What's the correlation between TRADELEGS, PVS and CREDIT_DERIVATIVES?
I guess you can relate a PV to a TRADELEG via the LEG_NUMBER, right? But what about CREDIT_DERIVATIVE to PV or to TRADELEG?
I need the output for TRADELEGS, PVS and CREDIT_DERIVATIVES.
Explain what that output should look like.

Similar Messages

  • Parsing XML stored in CLOB (PL/SQL)

    Hello,
    I would like to parse XML document like the example below.
    When it is stored in VARCHAR2 column, parsing works well.
    When it is stored in CLOB column, I get error message:
    "ORA-20100: Error occurred while parsing: Invalid char in text."
    The <text> section contains valid characters of ISO-8859-2 encoding.
    If <text> section contains only ASCII compatible characters, parsing works well.
    <?xml version="1.0" encoding="ISO-8859-2"?>
    <body>
    <text> &igrave;&egrave;&oslash;}amiz&ugrave; </text>
    </body>
    Is it a bug? Or where is problem?
    Any help would be appreciated.

    I used such an example to parse several Varchar2 strings in a given DB session:
    BEGIN
    parser := xmlparser.newparser ;
    xmlparser.parsebuffer(parser,xmlout) ;
    domdoc := xmlparser.getDocument(parser) ;
    xmlparser.FREEPARSER(parser) ;
    parser.id := -1 ;
    nodes := xslprocessor.selectNodes(
    xmldom.makenode(domdoc),
    'Positionen/Position') ;
    for i in 1 .. xmldom.getLength(nodes) loop
    node := xmldom.item(nodes,i-1) ;
    -- do s/thing with the node
    end loop ;
    xmldom.freedocument(domdoc) ;
    RETURN(komponenten) ;
    EXCEPTION
    WHEN OTHERS THEN
    if parser.id <> -1 then xmlparser.freeparser(parser) ;
    end if ;
    if domdoc.id <> -1 then xmldom.freedocument(domdoc) ;
    end if ;
    RAISE ;
    END ;
    However, after about 2000 of nodes lists parsed, I get an ArrayIndexOutOfBoundsException from XMLNodeCover. Obviously, I should release the nodes or the nodelist, but I have not found any procedure to do this.
    Pascal

  • Filtering xml records from CLOB database column

    Hi,
    I have a xml data stored in a CLOB field in database.
    I need to retrieve the contents that match my filter criteria.
    Say my xml is like below,
    <ROOT>
    <EMP>
    <EMP_NO>1</EMP_NO>
    <SAL>100</SAL>
    </EMP>
    <EMP>
    <EMP_NO>2</EMP_NO>
    <SAL>200</SAL>
    </EMP>
    <EMP>
    <EMP_NO>3</EMP_NO>
    <SAL>300</SAL>
    </EMP>
    </ROOT>
    I want to fetch the entire xml tree but filtered based on the SAL field, WHERE SAL>100.
    So my resulting xml should be
    <ROOT>
    <EMP>
    <EMP_NO>2</EMP_NO>
    <SAL>200</SAL>
    </EMP>
    <EMP>
    <EMP_NO>3</EMP_NO>
    <SAL>300</SAL>
    </EMP>
    </ROOT>
    I will be having 'n' number of columns, and I cant specify everything in COLUMNS clause.
    I want to select all nodes, but filter based on few fields.
    I tried using it as below, but I feel it took some time for it to display results.
    select x.*
    from emp t
    , xmltable(
    '/ROOT'
    passing xmltype(t.doc)
    columns VSAL number PATH './EMP/SAL'
    , OTHER xmltype PATH '.'
    ) x
    where x.VSAL>100
    Please suggest me a solution that doesnt consume much time.
    I think the problem with my query is OTHER xmltype PATH '.'
    Here 'xmltype' datatype is expensive I think, because after I included that, the query took some time.
    I cant hardcode the SAL value of 100 as its dynamic. So I am unable to use this method of filtering.
    select x.*
    from emp t
    , xmltable(
    '/ROOT[.//EMP/SAL>100]'
    passing xmltype(t.doc)
    ) x
    Thanks!
    Edited by: Chit on Mar 24, 2012 10:12 AM

    Hi,
    I want to fetch the entire xml tree but filtered based on the SAL field, WHERE SAL>100.Then you have to rebuild the document keeping only the elements satisfying the condition (and yes, you can bind XQuery variables too) :
    SQL> select xmlserialize(document x.doc as clob indent)
      2  from emp t
      3     , xmltable(
      4         '<ROOT>
      5          {
      6            for $i in /ROOT/EMP
      7            where $i/SAL > $minsal
      8            return $i
      9          }
    10          </ROOT>'
    11          passing xmlparse(document t.doc)
    12                , 100 as "minsal"
    13          columns doc xmltype path '.'
    14       ) x
    15  ;
    XMLSERIALIZE(DOCUMENTX.DOCASCL
    <ROOT>
      <EMP>
        <EMP_NO>2</EMP_NO>
        <SAL>200</SAL>
      </EMP>
      <EMP>
        <EMP_NO>3</EMP_NO>
        <SAL>300</SAL>
      </EMP>
    </ROOT>
    Or you can just delete the nodes you don't want :
    SQL> var minsal number
    SQL> exec :minsal := 100
    PL/SQL procedure successfully completed
    SQL> select xmlserialize(document
      2           deletexml( xmlparse(document t.doc)
      3                    , '/ROOT/EMP[SAL<='||:minsal||']' )
      4           as clob indent
      5         )
      6  from emp t
      7  ;
    XMLSERIALIZE(DOCUMENTDELETEXML
    <ROOT>
      <EMP>
        <EMP_NO>2</EMP_NO>
        <SAL>200</SAL>
      </EMP>
      <EMP>
        <EMP_NO>3</EMP_NO>
        <SAL>300</SAL>
      </EMP>
    </ROOT>
    Please suggest me a solution that doesnt consume much time.
    I think the problem with my query is OTHER xmltype PATH '.'The real problem is the CLOB text storage.
    If you want performance, use binary XMLType or object-relational.

  • Retrieve XML Data in clob type

    I have a table created as below
    create table tab123( x clob);
    Inserted a row as below
    insert into t values ('"<ProcessBatchRequest xmlns:inp1="http://services.abc.com/" ServiceVersionNumber="" xmlns="http://services.abc.com/GlobalBatchServiceV1.0">
    <inp1:BatchDetail>
    <inp1:ApplicationID>test.123</inp1:ApplicationID>
    <inp1:ApplicationBatchID>test.123</inp1:ApplicationBatchID>
    <inp1:MessageTimeStamp>2012-11-28T11:05:32.000-05:00</inp1:MessageTimeStamp>
    </inp1:BatchDetail>
    <inp1:CustomerIdentityDetail>
    <inp1:SubscriberNumber>123</inp1:SubscriberNumber>
    <inp1:UserUniqueID>1542</inp1:UserUniqueID>
    <inp1:SubscriberCountryISOAlpha2Code>AD</inp1:SubscriberCountryISOAlpha2Code>
    <inp1:ApplicationCustomerID>1210</inp1:ApplicationCustomerID>
    <inp1:ApplicationCustomerName>ABC</inp1:ApplicationCustomerName>
    <inp1:ApplicationUserID>ABC</inp1:ApplicationUserID>
    </inp1:CustomerIdentityDetail>
    <inp1:BatchSpecification>
    <inp1:BatchProcessID>Clean</inp1:BatchProcessID>
    <inp1:BatchPriorityValue>10</inp1:BatchPriorityValue>
    <inp1:LanguagePreferenceCode>39</inp1:LanguagePreferenceCode>
    <inp1:CharacterSetPreferenceCode>23423</inp1:CharacterSetPreferenceCode>
    <inp1:MatchSpecification>
    <inp1:ConfidenceLowerLevelThresholdValue>8</inp1:ConfidenceLowerLevelThresholdValue>
    <inp1:ConfidenceFallbackLowerLevelThresholdValue>4</inp1:ConfidenceFallbackLowerLevelThresholdValue>
    <inp1:ReturnAllFallbackMatchCandidatesIndicator>false</inp1:ReturnAllFallbackMatchCandidatesIndicator>
    <inp1:ExclusionCriteria>
    <inp1:ExclusionDataDescription>Small</inp1:ExclusionDataDescription>
    </inp1:ExclusionCriteria>
    <inp1:ReturnCleansedInformationIndicator>false</inp1:ReturnCleansedInformationIndicator>
    <inp1:MatchOnSeniorPrincipalNameIndicator>0</inp1:MatchOnSeniorPrincipalNameIndicator>
    </inp1:MatchSpecification>
    <inp1:CleanseSpecification>
    <inp1:ParseOnlyIndicator>0</inp1:ParseOnlyIndicator>
    <inp1:ProcessAsDiscreteDataIndicator>1</inp1:ProcessAsDiscreteDataIndicator>
    <inp1:ReturnDatainMixedCaseIndicator>0</inp1:ReturnDatainMixedCaseIndicator>
    <inp1:DoNotReturnChangeOfAddressIndicator>1</inp1:DoNotReturnChangeOfAddressIndicator>
    <inp1:DoNotEnableDeliveryPointValidationIndicator>1</inp1:DoNotEnableDeliveryPointValidationIndicator>
    <inp1:DoNotReturnEnhancedLineofTravelIndicator>1</inp1:DoNotReturnEnhancedLineofTravelIndicator>
    <inp1:DoNotConvertRuralRouteToStreetAddressIndicator>1</inp1:DoNotConvertRuralRouteToStreetAddressIndicator>
    <inp1:DoNotReturnSuiteAddressDetailIndicator>1</inp1:DoNotReturnSuiteAddressDetailIndicator>
    </inp1:CleanseSpecification>
    </inp1:BatchSpecification>
    <inp1:InputDetail>
    <inp1:InputFileDetail>
    <inp1:FileURI>/mnt/auto/</inp1:FileURI>
    <inp1:FileLayoutName>Clean</inp1:FileLayoutName>
    <inp1:LanguageCode>36</inp1:LanguageCode>
    <inp1:CompressTypeValue>None</inp1:CompressTypeValue>
    <inp1:RecordsCount>5</inp1:RecordsCount>
    </inp1:InputFileDetail>
    </inp1:InputDetail>
    <inp1:OutputSpecification>
    <inp1:FileLocationURI>/mnt/auto/</inp1:FileLocationURI>
    </inp1:OutputSpecification>
    <inp1:NotificationDetail>
    <inp1:NotificationMethodValue>Test</inp1:NotificationMethodValue>
    <inp1:NotificationFrequencyValue>0</inp1:NotificationFrequencyValue>
    </inp1:NotificationDetail>
    <inp1:BatchReferenceDetail/>
    </ProcessBatchRequest>
    1 rows inserted.
    Now i want to retrieve the value present under a given xpath. Can anyone help with the query???

    Not sure why you're storing double quotes around your XML text.
    Anyway, here's a starting point for you...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '"<ProcessBatchRequest xmlns:inp1="http://services.abc.com/" ServiceVersionNumber="" xmlns="http://services.abc.com/GlobalBatchServiceV1.0">
      2    <inp1:BatchDetail>
      3      <inp1:ApplicationID>test.123</inp1:ApplicationID>
      4      <inp1:ApplicationBatchID>test.123</inp1:ApplicationBatchID>
      5      <inp1:MessageTimeStamp>2012-11-28T11:05:32.000-05:00</inp1:MessageTimeStamp>
      6    </inp1:BatchDetail>
      7    <inp1:CustomerIdentityDetail>
      8      <inp1:SubscriberNumber>123</inp1:SubscriberNumber>
      9      <inp1:UserUniqueID>1542</inp1:UserUniqueID>
    10      <inp1:SubscriberCountryISOAlpha2Code>AD</inp1:SubscriberCountryISOAlpha2Code>
    11      <inp1:ApplicationCustomerID>1210</inp1:ApplicationCustomerID>
    12      <inp1:ApplicationCustomerName>ABC</inp1:ApplicationCustomerName>
    13      <inp1:ApplicationUserID>ABC</inp1:ApplicationUserID>
    14    </inp1:CustomerIdentityDetail>
    15    <inp1:BatchSpecification>
    16      <inp1:BatchProcessID>Clean</inp1:BatchProcessID>
    17      <inp1:BatchPriorityValue>10</inp1:BatchPriorityValue>
    18      <inp1:LanguagePreferenceCode>39</inp1:LanguagePreferenceCode>
    19      <inp1:CharacterSetPreferenceCode>23423</inp1:CharacterSetPreferenceCode>
    20      <inp1:MatchSpecification>
    21        <inp1:ConfidenceLowerLevelThresholdValue>8</inp1:ConfidenceLowerLevelThresholdValue>
    22        <inp1:ConfidenceFallbackLowerLevelThresholdValue>4</inp1:ConfidenceFallbackLowerLevelThresholdValue>
    23        <inp1:ReturnAllFallbackMatchCandidatesIndicator>false</inp1:ReturnAllFallbackMatchCandidatesIndicator>
    24        <inp1:ExclusionCriteria>
    25          <inp1:ExclusionDataDescription>Small</inp1:ExclusionDataDescription>
    26        </inp1:ExclusionCriteria>
    27        <inp1:ReturnCleansedInformationIndicator>false</inp1:ReturnCleansedInformationIndicator>
    28        <inp1:MatchOnSeniorPrincipalNameIndicator>0</inp1:MatchOnSeniorPrincipalNameIndicator>
    29      </inp1:MatchSpecification>
    30      <inp1:CleanseSpecification>
    31        <inp1:ParseOnlyIndicator>0</inp1:ParseOnlyIndicator>
    32        <inp1:ProcessAsDiscreteDataIndicator>1</inp1:ProcessAsDiscreteDataIndicator>
    33        <inp1:ReturnDatainMixedCaseIndicator>0</inp1:ReturnDatainMixedCaseIndicator>
    34        <inp1:DoNotReturnChangeOfAddressIndicator>1</inp1:DoNotReturnChangeOfAddressIndicator>
    35        <inp1:DoNotEnableDeliveryPointValidationIndicator>1</inp1:DoNotEnableDeliveryPointValidationIndicator>
    36        <inp1:DoNotReturnEnhancedLineofTravelIndicator>1</inp1:DoNotReturnEnhancedLineofTravelIndicator>
    37        <inp1:DoNotConvertRuralRouteToStreetAddressIndicator>1</inp1:DoNotConvertRuralRouteToStreetAddressIndicator>
    38        <inp1:DoNotReturnSuiteAddressDetailIndicator>1</inp1:DoNotReturnSuiteAddressDetailIndicator>
    39      </inp1:CleanseSpecification>
    40    </inp1:BatchSpecification>
    41    <inp1:InputDetail>
    42      <inp1:InputFileDetail>
    43        <inp1:FileURI>/mnt/auto/</inp1:FileURI>
    44        <inp1:FileLayoutName>Clean</inp1:FileLayoutName>
    45        <inp1:LanguageCode>36</inp1:LanguageCode>
    46        <inp1:CompressTypeValue>None</inp1:CompressTypeValue>
    47        <inp1:RecordsCount>5</inp1:RecordsCount>
    48      </inp1:InputFileDetail>
    49    </inp1:InputDetail>
    50    <inp1:OutputSpecification>
    51      <inp1:FileLocationURI>/mnt/auto/</inp1:FileLocationURI>
    52    </inp1:OutputSpecification>
    53    <inp1:NotificationDetail>
    54      <inp1:NotificationMethodValue>Test</inp1:NotificationMethodValue>
    55      <inp1:NotificationFrequencyValue>0</inp1:NotificationFrequencyValue>
    56    </inp1:NotificationDetail>
    57    <inp1:BatchReferenceDetail/>
    58  </ProcessBatchRequest>"' as xml_clob from dual)
    59  --
    60  -- end of test data
    61  --
    62  select b.*, c.*
    63  from   t
    64        ,xmltable(xmlnamespaces(default 'http://services.abc.com/GlobalBatchServiceV1.0', 'http://services.abc.com/' as "inp1"),
    65                  '/ProcessBatchRequest'
    66                  passing xmltype(trim('"' from xml_clob))
    67                  columns BD   XMLTYPE path './inp1:BatchDetail'
    68                         ,CID  XMLTYPE path './inp1:CustomerIdentityDetail'
    69                         ,BS   XMLTYPE path './inp1:BatchSpecification'
    70                         ,ID   XMLTYPE path './inp1:InputDetail'
    71                         ,OS   XMLTYPE path './inp1:OutputSpecification'
    72                 ) a
    73        ,xmltable(xmlnamespaces(default 'http://services.abc.com/GlobalBatchServiceV1.0', 'http://services.abc.com/' as "inp1"),
    74                  '/inp1:BatchDetail'
    75                  passing a.BD
    76                  columns App_ID    varchar2(10) path './inp1:ApplicationID'
    77                         ,AppBat_ID varchar2(10) path './inp1:ApplicationBatchID'
    78                         ,MsgTS     varchar2(30) path './inp1:MessageTimeStamp'
    79                 ) b
    80        ,xmltable(xmlnamespaces(default 'http://services.abc.com/GlobalBatchServiceV1.0', 'http://services.abc.com/' as "inp1"),
    81                  '/inp1:CustomerIdentityDetail'
    82                  passing a.CID
    83                  columns Sub_No      number       path './inp1:SubscriberNumber'
    84                         ,UUID        number       path './inp1:UserUniqueID'
    85                         ,Sub_Country varchar2(2)  path './inp1:SubscriberCountryISOAlpha2Code'
    86                         ,App_Cust_ID number       path './inp1:ApplicationCustomerID'
    87                         ,App_Cust_Nm varchar2(10) path './inp1:ApplicationCustomerName'
    88                         ,App_User_ID varchar2(10) path './inp1:ApplicationUserID'
    89*                ) c
    SQL> /
    APP_ID     APPBAT_ID  MSGTS                              SUB_NO       UUID SU APP_CUST_ID APP_CUST_N APP_USER_I
    test.123   test.123   2012-11-28T11:05:32.000-05:00         123       1542 AD        1210 ABC        ABC
    SQL>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Validating XML stored in CLOB without exceptions for malformed XML

    Hello,
    I have a CLOB column that should contain an XML which conforms to a registered XSD schema. However, there might also be cases, in which the CLOB content violates the XSD or is not even wellformed XML at all.  Now I am trying to find a way to either
    identify all records, for which the CLOB contains well-formed XML that validates against my schema (find all "good" records) , or
    find all the other records (those with either no XML at all, malformed XML, or XML that does not validate against the XSD) (find all "exceptions")
    The problem is that all XML-validation methods I know of (e.g. isXmlValid or XmlType.isSchemaValid)  require an XmlType instance, and that records, for which no proper XmlType can be constructed from the CLOB, because the CLOB does not contain well-formed XML, will cause an exception, rather than just returning false or NULL or something else I could filter out.
    Is there a way to do something like
    SELECT * FROM MYTABLE where <MY_XML_COL is wellformed XML> and <MY_XML_COL validates against 'blabla.xsd'>
    without getting an ORA-31011 or whatever other kind of exception as soon as there is a row that does not contain proper XML?
    Thank you...

    So here is my example - this will be quiet a long post now...
    First, I create the table with the CLOBs
    CREATE TABLE ZZZ_MINITEST_CLOB (
      ID NUMBER(10,0) NOT NULL ENABLE,
      XML_DOC CLOB,
      REMARKS VARCHAR2(1000),
      CONSTRAINT PK_ZZZ_MINITEST_CLOB PRIMARY KEY (ID)
    ) NOLOGGING;
    Then I insert some examples
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    10,
    '<minitest_root>
      <l2Node>
      <l2Num>1</l2Num>
      <l2Name>one.one</l2Name>
      </l2Node>
      <minitestId>1</minitestId>
      <minitestName>One</minitestName>
    </minitest_root>',
    'Basic valid example');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    20,
    '<minitest_root>
      <l2Node>
      <l2Num>1</l2Num>
      <l2Name>two.one</l2Name>
      </l2Node>
      <minitestId>2</minitestId>
      <!-- minitestName element is missing -->
    </minitest_root>',
    'Invalid - minitestName element is missing');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    30,
    '<minitest_root>
      <l2Node>
      <l2Num>1</l2Num>
      <l2Name>three.one</l2Name>
      </l2Node>
      <!-- minitestName and minitestId are switched -->
      <minitestName>Three</minitestName>
      <minitestId>3</minitestId>
    </minitest_root>',
    'Invalid - minitestName and minitestId are switched');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    40,
    '<minitest_root>
      <l2Node>
      <l2Num>1</l2Num>
      <l2Name>four.one</l2Name>
      </l2Node>
      <l2Node>
      <l2Num>2</l2Num>
      <l2Name>four.two</l2Name>
      </l2Node>
      <l2Node>
      <l2Num>3</l2Num>
      <l2Name>four.three</l2Name>
      </l2Node>
      <minitestId>4</minitestId>
      <minitestName>Four</minitestName>
    </minitest_root>',
    'Valid - multiple l2Node elements');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    50,
    '<minitest_root>
      <l2Node>
      <l2Num>1</l2Num>
      <l2Name>five.one</l2Name>
      </l2Node>
      <l2Node>
      <l2Num>2</l2Num>
      <l2Name>five.two</l2Name>
      </l2Node>
      <minitestId>4</minitestId>
      <minitestName>Five</minitestName>
      <!-- another l2Node node, but too far down -->
      <l2Node>
      <l2Num>3</l2Num>
      <l2Name>five.three</l2Name>
      </l2Node>
    </minitest_root>',
    'Invalid - another l2Node node, but too far down');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    60,
    'something that is not even xml',
    'Invalid - something that is not even xml');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    70,
    NULL,
    'Invalid - good old NULL');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    80,
    '<minitest_root>
      <l2Node>
      <l2Num>1</l2Num>
      <l2Name>
      <unexpected_node>
      this one should not be here!
      </unexpected_node>
      </l2Name>
      </l2Node>
      <minitestId>8</minitestId>
      <minitestName>Eight</minitestName>
    </minitest_root>',
    'Invalid - unexpected addl node');
    INSERT INTO ZZZ_MINITEST_CLOB VALUES (
    90,
    '<something> that has tags but is no xml </either>',
    'Invalid - something that has tags but is no xml either');
    COMMIT;
    Next I register the XSD...
    BEGIN
    DBMS_XMLSCHEMA.REGISTERSCHEMA(
      'http://localhost/minitest.xsd',
      '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:storeVarrayAsTable="true" oraxdb:schemaURL="http://localhost/minitest.xsd">
      <xs:element name="minitest_root" oraxdb:SQLName="MINITEST_ROOT" oraxdb:SQLType="MINITEST_TYPE" oraxdb:defaultTable="" oraxdb:tableProps="NOLOGGING" oraxdb:maintainDOM="false">
        <xs:complexType oraxdb:SQLType="MINITEST_TYPE" oraxdb:maintainDOM="false">
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="l2Node" oraxdb:SQLName="L2_NODE" oraxdb:SQLType="L2_NODE_TYPE" oraxdb:SQLCollType="L2_NODE_COLL" oraxdb:maintainDOM="false"/>
            <xs:element ref="minitestId" oraxdb:SQLName="MINITEST_ID" oraxdb:SQLType="NUMBER" oraxdb:maintainDOM="false"/>
            <xs:element ref="minitestName" oraxdb:SQLName="MINITEST_NAME" oraxdb:SQLType="VARCHAR2" oraxdb:maintainDOM="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="l2Node" oraxdb:SQLName="L2_NODE" oraxdb:SQLType="L2_NODE_TYPE" oraxdb:defaultTable="" oraxdb:tableProps="TABLESPACE CATALOG NOLOGGING" oraxdb:maintainDOM="false">
        <xs:complexType oraxdb:SQLType="L2_NODE_TYPE" oraxdb:maintainDOM="false">
          <xs:sequence>
            <xs:element ref="l2Num" oraxdb:SQLName="L2_NUM" oraxdb:SQLType="NUMBER" oraxdb:maintainDOM="false"/>
            <xs:element ref="l2Name" oraxdb:SQLName="L2_NAME" oraxdb:SQLType="VARCHAR2" oraxdb:maintainDOM="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="l2Num" type="number10_0Type" oraxdb:SQLName="L2_NUM" oraxdb:SQLType="NUMBER" oraxdb:maintainDOM="false" />
      <xs:element name="l2Name" type="varchar100Type" oraxdb:SQLName="L2_NAME" oraxdb:SQLType="VARCHAR2" oraxdb:maintainDOM="false" />
      <xs:element name="minitestId" type="number10_0Type" oraxdb:SQLName="MINITEST_ID" oraxdb:SQLType="NUMBER" oraxdb:maintainDOM="false" />
      <xs:element name="minitestName" type="varchar100Type" oraxdb:SQLName="MINITEST_NAME" oraxdb:SQLType="VARCHAR2" oraxdb:maintainDOM="false" />
      <xs:simpleType name="varchar100Type">
        <xs:restriction base="xs:string">
          <xs:maxLength value="100"/>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType name="number10_0Type">
        <xs:restriction base="xs:integer">
          <xs:totalDigits value="10"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:schema>',
      GENTABLES=>FALSE
    END;
    And then I create my XML tables - four different ones for four different test cases. I am trying unstructured binary XML and strucured OR-based XML, each with and without a trigger.
    One with structured OR storage and no trigger
    CREATE TABLE ZZZ_MINITEST_ORXML (
      ID NUMBER(10,0) NOT NULL ENABLE,
      XML_CONTENT XMLTYPE,
      CONSTRAINT PK_ZZZ_MINITEST_ORXML PRIMARY KEY (ID)
    ) NOLOGGING
    VARRAY "XML_CONTENT"."XMLDATA"."L2_NODE" STORE AS TABLE "ZZZ_OR_L2_NODE" (NOLOGGING) RETURN AS LOCATOR
    XMLTYPE XML_CONTENT STORE AS OBJECT RELATIONAL XMLSCHEMA "http://localhost/minitest.xsd" ELEMENT "minitest_root";
    One with structured OR storage which will also have a trigger added further down
    CREATE TABLE ZZZ_MINITEST_ORXML_TRGR (
      ID NUMBER(10,0) NOT NULL ENABLE,
      XML_CONTENT XMLTYPE,
      CONSTRAINT PK_ZZZ_MINITEST_ORXML_TRGR PRIMARY KEY (ID)
    ) NOLOGGING
    VARRAY "XML_CONTENT"."XMLDATA"."L2_NODE" STORE AS TABLE "ZZZ_OR_L2_NODE_TRGR" (NOLOGGING) RETURN AS LOCATOR
    XMLTYPE XML_CONTENT STORE AS OBJECT RELATIONAL XMLSCHEMA "http://localhost/minitest.xsd" ELEMENT "minitest_root";
    One with unstructured binary XML in a SECUREFILE, no trigger
    CREATE TABLE ZZZ_MINITEST_BINXML_TRGR (
      ID NUMBER(10,0) NOT NULL ENABLE,
      XML_CONTENT XMLTYPE,
      CONSTRAINT PK_ZZZ_MINITEST_BINXML_TRGR PRIMARY KEY (ID)
    ) NOLOGGING
    XMLTYPE COLUMN XML_CONTENT STORE AS SECUREFILE BINARY XML
      (NOCOMPRESS NOCACHE NOLOGGING KEEP_DUPLICATES);
    One with unstructured binary XML in a SECUREFILE, which will also have a trigger
    CREATE TABLE ZZZ_MINITEST_BINXML (
      ID NUMBER(10,0) NOT NULL ENABLE,
      XML_CONTENT XMLTYPE,
      CONSTRAINT PK_ZZZ_MINITEST_BINXML PRIMARY KEY (ID)
    ) NOLOGGING
    XMLTYPE COLUMN XML_CONTENT STORE AS SECUREFILE BINARY XML
      (NOCOMPRESS NOCACHE NOLOGGING KEEP_DUPLICATES);
    Then I create the error logging tables
    begin
    DBMS_ERRLOG.CREATE_ERROR_LOG ('ZZZ_MINITEST_BINXML', 'ZZZ_MINITEST_BINXML_E', NULL, NULL, TRUE);
    DBMS_ERRLOG.CREATE_ERROR_LOG ('ZZZ_MINITEST_BINXML_TRGR', 'ZZZ_MINITEST_BINXML_TRGR_E', NULL, NULL, TRUE);
    DBMS_ERRLOG.CREATE_ERROR_LOG ('ZZZ_MINITEST_ORXML', 'ZZZ_MINITEST_ORXML_E', NULL, NULL, TRUE);
    DBMS_ERRLOG.CREATE_ERROR_LOG ('ZZZ_MINITEST_ORXML_TRGR', 'ZZZ_MINITEST_ORXML_TRGR_E', NULL, NULL, TRUE);
    END;
    Now the two triggers
    create or replace trigger TRG_ZZZ_MINITEST_BINXML
    BEFORE UPDATE OR INSERT ON ZZZ_MINITEST_BINXML_TRGR
    REFERENCING NEW AS NEW
    for each row
    BEGIN
      :NEW.XML_CONTENT := :NEW.XML_CONTENT.createSchemaBasedXML('http://localhost/minitest.xsd');
      :NEW.XML_CONTENT.SCHEMAVALIDATE();
    END TRG_ZZZ_MINITEST_BINXML;
    CREATE OR REPLACE TRIGGER TRG_ZZZ_MINITEST_ORXML
    BEFORE UPDATE OR INSERT ON ZZZ_MINITEST_ORXML_TRGR
    REFERENCING NEW AS NEW
    for each row
    BEGIN
      :NEW.XML_CONTENT := :NEW.XML_CONTENT.createSchemaBasedXML('http://localhost/minitest.xsd');
      :NEW.XML_CONTENT.SCHEMAVALIDATE();
    END TRG_ZZZ_MINITEST_ORXML;
    I also tried to just validate the XML using queries such as the below, since validating all without the WHERE also caused exception and abortion:
    SELECT ID, DECODE(XMLISVALID(XMLTYPE(XML_DOC), 'http://localhost/minitest.xsd'), 1, 'Y', 0, 'N', '?') VALID
    FROM ZZZ_MINITEST_CLOB WHERE ID=90;
    The results are in column "VALID" in the below tables
    I tried inserting all records from ZZZ_MINITEST_CLOB into the four test tables at once using a query such as
    INSERT INTO ZZZ_MINITEST_ORXML_TRGR
    SELECT ID, XMLPARSE(DOCUMENT XML_DOC WELLFORMED) FROM ZZZ_MINITEST_CLOB
    LOG ERRORS INTO ZZZ_MINITEST_ORXML_TRGR_E REJECT LIMIT UNLIMITED;
    I also tried different versions of creating the XML in the SELECT portion:
    XMLPARSE(DOCUMENT XML_DOC WELLFORMED)
    XMLPARSE(DOCUMENT XML_DOC WELLFORMED)
    XMLTYPE(XML_DOC)
    XMLTYPE(XMLDOC, 'http://localhost/minitest.xsd', 0, 1)
    Almost all combinations of the four test tables with the four ways to instantiate the XML caused exceptions and query abortion despite the LOG ERRORS INTO clause.
    In order to find the exact problems, I started inserting records one by one using queries like
    INSERT INTO ZZZ_MINITEST_ORXML
    SELECT ID, XMLPARSE(DOCUMENT XML_DOC) FROM ZZZ_MINITEST_CLOB WHERE ID=10
    LOG ERRORS INTO ZZZ_MINITEST_ORXML_E REJECT LIMIT UNLIMITED;
    or
    INSERT INTO ZZZ_MINITEST_BINXML_TRGR
    SELECT ID, XMLTYPE(XMLDOC, 'http://localhost/minitest.xsd', 0, 1) FROM ZZZ_MINITEST_CLOB WHERE ID=20
    LOG ERRORS INTO ZZZ_MINITEST_BINXML_TRGR_E REJECT LIMIT UNLIMITED;
    I captured the results of each in the below four tables. "1" and "0" are number of rows inserted. 0 means there was no record inserted and instead, there was an error logged in the ERROR LOGGING table.
    The ORA-????? exception numbers mean that this error actually caused the INSERT to fail and abort rather than just being logged in the LOGGING TABLE.These are the most critical cases for me. Why do these exceptions "bubble up" forcing the query to be aborted rather than being logged in the error log as well???
    This table is for INSERT of XMLs using XMLTYPE(XML_DOC)
    Test case
    VALID
    Binary XML,
    no trigger
    Binary XML,
    trigger
    OR XML,
    no trigger
    OR XML,
    trigger
    10
    Good
    Y
    1
    1
    1
    1
    20
    no name
    N
    1
    0
    1
    0
    30
    switched tags
    N
    1
    1
    1
    1
    40
    Good
    Y
    1
    1
    1
    1
    50
    L2 down
    N
    1
    1
    1
    1
    60
    no xml
    EX
    ORA-31011
    ORA-31011
    ORA-31011
    ORA-31011
    70
    NULL
    EX
    ORA-06502
    ORA-06502
    ORA-06502
    ORA-06502
    80
    addl. Node
    N
    1
    0
    ORA-31187
    ORA-31187
    90
    crappy xml
    EX
    ORA-31011
    ORA-31011
    ORA-31011
    ORA-31011
    This table is for INSERT of XMLs using XMLTYPE(XML_DOC, 'http://localhost/minitest.xsd', 0, 1)
    Test case
    VALID
    Binary XML,
    no trigger
    Binary XML,
    trigger
    OR XML,
    no trigger
    OR XML,
    trigger
    10
    Good
    Y
    1
    1
    1
    1
    20
    no name
    N
    1
    0
    1
    0
    30
    switched tags
    N
    1
    1
    1
    1
    40
    Good
    Y
    1
    1
    1
    1
    50
    L2 down
    N
    1
    1
    1
    1
    60
    no xml
    EX
    ORA-31043
    ORA-31043
    ORA-31043
    ORA-31043
    70
    NULL
    EX
    ORA-06502
    ORA-06502
    ORA-06502
    ORA-06502
    80
    addl. Node
    N
    1
    0
    ORA-31187
    ORA-31187
    90
    crappy xml
    EX
    ORA-31043
    ORA-31043
    ORA-31043
    ORA-31043
    This table is for INSERT of XMLs using XMLPARSE(DOCUMENT XML_DOC WELLFORMED)
    Test case
    VALID
    Binary XML,
    no trigger
    Binary XML,
    trigger
    OR XML,
    no trigger
    OR XML,
    trigger
    10
    Good
    Y
    1
    1
    1
    1
    20
    no name
    N
    1
    0
    1
    0
    30
    switched tags
    N
    1
    1
    1
    1
    40
    Good
    Y
    1
    1
    1
    1
    50
    L2 down
    N
    1
    1
    1
    1
    60
    no xml
    ORA-31061
    0
    ORA-31011
    ORA-31011
    70
    NULL
    1
    0
    1
    0
    80
    addl. Node
    N
    0
    0
    ORA-31187
    ORA-31187
    90
    crappy xml
    ORA-31061
    0
    ORA-30937
    ORA-30937
    This table is for INSERT of XMLs using XMLPARSE(DOCUMENT XML_DOC) (same as above, but without "WELLFORMED")
    Test case
    VALID
    Binary XML,
    no trigger
    Binary XML,
    trigger
    OR XML,
    no trigger
    OR XML,
    trigger
    10
    Good
    Y
    1
    1
    1
    1
    20
    no name
    N
    1
    0
    1
    0
    30
    switched tags
    N
    1
    1
    1
    1
    40
    Good
    Y
    1
    1
    1
    1
    50
    L2 down
    N
    1
    1
    1
    1
    60
    no xml
    ORA-31011
    ORA-31011
    ORA-31011
    ORA-31011
    70
    NULL
    1
    0
    1
    0
    80
    addl. Node
    N
    1
    0
    ORA-31187
    ORA-31187
    90
    crappy xml
    ORA-31011
    ORA-31011
    ORA-31011
    ORA-31011
    As you can see, different ways to instantiate the XML which is being inserted will cause different results for the most critical cases (60, 80 and 90). One will go through with an error logged in the logging table and no record inserted, others cause exceptions. Also, using XMLPARSE with or without WELLFORMED causes different ORA numbers for record 90...
    It seems like the only way to not get any exceptions for my test records is inserting XMLs that were created using XMLPARSE (DOCUMENT ... WELLFORMED) into the trigger-protected binary XML table. However, that causes me to miss record number 80, which is one that I really need, because it is well formed and I could use XSLTs to fix the XML by removing the extra tags, as long as I know which ones those are.

  • How to publish XML document whose source is stored in clob column

    I have to create simple application:
    in one table are stored some information about XML documents (date of creation, etc.) and the document source itself in one (unfortunatelly clob type) column.
    The point is to anable users finding document(s) and viewing it.
    Using forms I can search and display information about documents. But I have no idea how to publish XML document whose source is stored in clob column.
    I am using Oracle Portal 3.0 on NT.
    Thanks in advance.

    Hi Sergio,
    This link might be helpful:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
    Also refer the BLOB Download Format Mask :
    {message:id=9716335}
    Here I have given the format mask for APEX 4.0, which will slightly differ for 3.2.1 and proposed changes
    in the format mask are:
    1) Format Mask: DOWNLOAD
    2) Content Disposition: Inline
    This will be achieved with it:
    >
    But now, my user would like to know if it´s possible that APEX application can OPEN some of these files stored on this BLOB column WITHOUT download it.
    My user would like to see a hiperlink (or button) that, if pressed/acessed, can open a new page (or a page inside application) with the document. He doesn´t need to edit this oppened file. He only wants to see it.
    >
    Hope it helps!
    Regards,
    Kiran

  • Update XML data stored in CLOB Column

    Hi All,
    i am new to Oracle and new to SQL
    i am trying to update XML data stored in CLOB cloumn,data is stored with the follwoing format
    <attrs><attr name="name"><string>Schade</string></attr></attrs>
    i am using the following query for updating the value
    UPDATE PRODUCT p SET ATTRIBUTES_nl_nl=UPDATEXML(XMLTYPE.createXML(ATTRIBUTES_nl_nl),'/attrs/attr[@name="name"]/string/text()','Schade').getClobVal() WHERE p.sku='000000000000040576_200911-5010057'
    this query is working fine but it changing the data to the following format
    <attrs><attr name="name">Schade</attr></attrs>
    some how it is ommiting the <string> tag from it, i am unable to figure it out whats the reason.
    any help in this regard will b e much appriciated
    Thanks in Advance
    -Umesh

    Hi,
    You should have created your own thread for this, and included database version.
    This works for me on 11.2.0.2 and 10.2.0.5 :
    SQL> create table t_org ( xml_clob clob );
    Table created
    SQL>
    SQL> insert into t_org
      2  values(
      3  '<Message>
      4  <Entity>
      5  <ASSIGNMENT>
      6  <OAVendorLocation> </OAVendorLocation>
      7  <Vendorid>1</Vendorid>
      8  </ASSIGNMENT>
      9  </Entity>
    10  </Message>'
    11  );
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> select '*' ||
      2         extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
      3         || '*' as result
      4  from t_org;
    RESULT
    SQL> update t_org set xml_clob =
      2  updatexml(xmltype(xml_clob),
      3  '/Message/Entity/ASSIGNMENT/OAVendorLocation/text()','LONDON').getClobVal()
      4  ;
    1 row updated
    SQL> select '*' ||
      2         extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
      3         || '*' as result
      4  from t_org;
    RESULT
    *LONDON*
    Does the OAVendorLocation really have a whitespace value?
    If not then it's expected behaviour, you're trying to update a text() node that doesn't exist. In this case, the solution is to use appendChildXML to create the text() node, or update the whole element.
    Is it your real document? Do you actually have some namespaces?

  • Intermedia text search in XML document stored as CLOB

    Suppose i store an XML document as clob
    and i index it based on the tags ie
    if i have the followind table
    create table biodata (
    resume_id number primary key,
    content clob default empty_clob(),
    applicant_id number references
    applicants(id));
    and i stores various resumes in the clob (content column ) as xml document ie
    <experience_in_months> 22 </experience_in_months>
    Now if i want all the resume_id that that have experiences_in_months >= 10
    what would be the query that would fetch me this result?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by voron:
    We are storing data in XML format in an Oracle database (via CLOB). I can retrieve search results using the 'within' phrase, but am finding it hard to order them. Is there a utility or command I can use?<HR></BLOCKQUOTE>
    Maybe you should write a stored procedure (function )
    that extracts the section from your clob
    that should be sorted. Then use this function
    in the ORDER clause of your select statement.
    Andreas
    null

  • Want to retrieve multiple XML fragments in CLOBs in a *single query*

    Hi,
    I am trying to retrieve some well formed XML fragments stored as CLOBs from an 8i DB. For a single fragment at a time this is not a problem using <xsql:include-xml>. However, I am trying to retrieve multiple well formed fragments in a single query, "stacked" like so...
    <xsql:include-xml>
    <![CDATA[
    select theXMLFrag from tclob1 where id = 'open'
    union all
    select theXMLFrag from tclob2 --returns multiple rows
    union all
    select theXMLFrag from tclob3 --some more rows
    union all
    select theXMLFrag from tclob1 where id = 'close'
    ]]>
    </xsql:include-xml>
    What I am really after are the contents from the middle two selects. (The 'open' and 'close' bit was just a cheap attempt to ensure that the included XML is well formed.) Though it is not shown in my example, the problem is that the number and source of the CLOB fragments is not known until run time, and I wanted to use a dynamic query to assemble the needed CLOBS...
    I have since learned that <xsql:include-xml> returns the first column of the first row of the query result as parsed XML, either from a CLOB or a VARCHAR containing well-formed XML. So my attempt is no good... all but the first row are ignored.
    Does anyone have any suggestions for a way to do this using the existing xsql tag library? Or will I need to create my own <xsql:action>?
    Thanks,
    Bob Nugent

    Hi,
    Let me correct if i am right:
    - Central Contract -> new concept of SRM 7.0. 1 contract which is visible and usable from ECC and SRM as well. (not available in SRM 5.0 - agree)
    - GOA -> it exist in SRM 5.0 for sure! (we are currenlty using it for ECC procurement).
    The solution what you are mentioned is good...but as you said only for SRM 70...we are in SRM 5.0 and we need solution for here. Do you have any idea?
    Currently i am thinking about a new solution based on "standard" functionalities: if a GOA need to be created for mulitple company, it has to be populated in Header distribution (all company will have the same contract header). It item detail all the required information need to be poupulate in SRM (i.e.: item 1 for p.org1/comp.cod1; item 2 for p.org2/comp.cod2).
    When this is done, the BADI need to check the informatoin in SRM GOA and create contract according to that -> in this case 1GOA is created, but the 2 items for totally different p.org/comp.code, the BADI needs to create 2 different contract in ECC (i would like to avoid using reference purchasing organization in ECC!
    Thanks in advance!
    Best Regards,
    Attila

  • Parse a xml file from clob column.

    Dear,
    i have been suffreing a problem about xml.
    i have a table with two columns, one is bfile data type other is clob data type. A xml data is stored into both cloumns
    as clob and bfile. My xml data format is correct.
    when i took xml data from bfile column, then dbms_xmlparser.parseClob successfully parse my xml data.
    Code below:
    =======================================
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.loadFromFile(dest_lob => l_clob,
    src_lob => l_bfile,
    amount => dbms_lob.getLength(l_bfile));
    l_parser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseClob(l_parser, l_clob); ========================================
    But when i took xml data form clob clumn directly, then dbms_xmlparser.parseClob parse failed and go to exception.
    Code below:
    ====================================================================
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    select xml_cfile,xml_bfile                    
    into l_clob ,l_bfile
    from xml_load_in
    l_parser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseClob(l_parser, l_clob); --failed parse    
    ====================================================================
    declare
    l_bfile BFILE;
    l_clob CLOB;
    l_parser dbms_xmlparser.Parser;
    l_doc dbms_xmldom.DOMDocument;
    begin
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    select xml_cfile,xml_bfile
    into l_clob ,l_bfile
    from xml_load_in
    l_parser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseClob(l_parser, l_clob);
    l_doc := dbms_xmlparser.getDocument(l_parser);
    dbms_lob.freetemporary(l_clob);
    dbms_xmlparser.freeParser(l_parser);
    exception
    dbms_lob.freetemporary(l_clob);
    dbms_xmlparser.freeParser(l_parser);
    dbms_xmldom.freeDocument(l_doc);
    End;
    Example:
    ======--File_name := Outward.xml;
    CREATE OR REPLACE DIRECTORY
    MY_INWARD AS
    'D:\PBM\Inward\';
    CREATE TABLE XML_LOAD_IN
    ( XML_CFILE CLOB,
    XML_BFILE BFILE
    INSERT INTO XML_LOAD_IN ( XML_CFILE, XML_BFILE )
    VALUES (
    '<?xml version="1.0" encoding="UTF-8"?>
    <BACPSInterface>
    <OCE>
    <EHR>
    <StandardLevel>03</StandardLevel>
    <TestFiledIndicator>T</TestFiledIndicator>
    <ImmediateDestRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ImmediateDestRoutingNumber>
    <ImmediateOriginRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ImmediateOriginRoutingNumber>
    <FileCreationDate>20090714</FileCreationDate>
    <FileCreationTime>1047</FileCreationTime>
    <ResendIndicator>N</ResendIndicator>
    <ECESettlementDate>20090714</ECESettlementDate>
    <ECESessionTime>1047</ECESessionTime>
    <ECESettlementTime>1047</ECESettlementTime>
    <ECEtype>01</ECEtype>
    <CountryCode>BD</CountryCode>
    </EHR>
    <Collection>
    <CHR>
    <CashLetterBusinessDate>20090714</CashLetterBusinessDate>
    <CashLetterCreationDate>20090714</CashLetterCreationDate>
    <CashLetterCreationTime>1047</CashLetterCreationTime>
    <CashLetterRecordTypeInd>I</CashLetterRecordTypeInd>
    <CashLetterDocTypeIndicator>G</CashLetterDocTypeIndicator>
    <CashLetterID>1</CashLetterID>
    <OriginatorContactName>Bank Asia</OriginatorContactName>
    <OriginatorContactPhoneNumber>XXX</OriginatorContactPhoneNumber>
    </CHR>
    <ForwardBundle>
    <BHR>
    <CollectionTypeIndicator>I</CollectionTypeIndicator>
    <DestRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </DestRoutingNumber>
    <ECEInstitutionRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ECEInstitutionRoutingNumber>
    <BundleBusinessDate>20090714</BundleBusinessDate>
    <BundleCreationDate>20090714</BundleCreationDate>
    <BundleID>1</BundleID>
    <ReturnLocationRoutingNumber>070127538</ReturnLocationRoutingNumber>
    </BHR>
    <CDR>
    <CDR num="1">
    <ECESettlementDate>20090714</ECESettlementDate>
    <ECESessionTime>1047</ECESessionTime>
    <ECESettlementTime>1047</ECESettlementTime>
    <ECEItemType>N</ECEItemType>
    <IssuingBranchRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </IssuingBranchRoutingNumber>
    <AccountNumber>0000334008221</AccountNumber>
    <ChequeSequenceNumber>1601735</ChequeSequenceNumber>
    <ItemAmount>500</ItemAmount>
    <ECEInstitutionItemSequencNum>0701275380000001</ECEInstitutionItemSequencNum>
    <DocumentationTypeIndicator>I</DocumentationTypeIndicator>
    <ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
    <MICRValidIndicator>1</MICRValidIndicator>
    <BOFDIndicator>Y</BOFDIndicator>
    <ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
    <CorrectionIndicator>0</CorrectionIndicator>
    <RepresentmentIndicator>0</RepresentmentIndicator>
    <ArchiveTypeIndicator>F</ArchiveTypeIndicator>
    </CDR>
    <CDR num="2">
    <ECESettlementDate>20090714</ECESettlementDate>
    <ECESessionTime>1047</ECESessionTime>
    <ECESettlementTime>1047</ECESettlementTime>
    <ECEItemType>N</ECEItemType>
    <IssuingBranchRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </IssuingBranchRoutingNumber>
    <AccountNumber>0000345682256</AccountNumber>
    <ChequeSequenceNumber>1234567</ChequeSequenceNumber>
    <ItemAmount>1000</ItemAmount>
    <ECEInstitutionItemSequencNum>0701275380000002</ECEInstitutionItemSequencNum>
    <DocumentationTypeIndicator>I</DocumentationTypeIndicator>
    <ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
    <MICRValidIndicator>1</MICRValidIndicator>
    <BOFDIndicator>Y</BOFDIndicator>
    <ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
    <CorrectionIndicator>0</CorrectionIndicator>
    <RepresentmentIndicator>0</RepresentmentIndicator>
    <ArchiveTypeIndicator>F</ArchiveTypeIndicator>
    </CDR>
    </CDR>
    <CDA>
    <CDA num="1">
    <AddendumRecordNumber>1</AddendumRecordNumber>
    <BOFDRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>75</DistrictCode>
    <BranchCode>12</BranchCode>
    <CheckDigit>8</CheckDigit>
    </BOFDRoutingNumber>
    <BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
    <BOFDDepositAccountNumber>0000334008221</BOFDDepositAccountNumber>
    <BOFDDepositBranch>753</BOFDDepositBranch>
    <PayeeName>XXX</PayeeName>
    <TruncationIndicator>Y</TruncationIndicator>
    <BOFDConversionIndicator>2</BOFDConversionIndicator>
    <BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
    </CDA>
    <CDA num="2">
    <AddendumRecordNumber>1</AddendumRecordNumber>
    <BOFDRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>75</DistrictCode>
    <BranchCode>12</BranchCode>
    <CheckDigit>8</CheckDigit>
    </BOFDRoutingNumber>
    <BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
    <BOFDDepositAccountNumber>0000345682256</BOFDDepositAccountNumber>
    <BOFDDepositBranch>753</BOFDDepositBranch>
    <PayeeName>XXX</PayeeName>
    <TruncationIndicator>Y</TruncationIndicator>
    <BOFDConversionIndicator>2</BOFDConversionIndicator>
    <BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
    </CDA>
    </CDA>
    <CDC>
    <CDC num="1">
    <AddendumCRecordNumber>1</AddendumCRecordNumber>
    <EndorsingBankRountingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </EndorsingBankRountingNumber>
    <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
    <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
    <EndorsingBankItemSequenceNum>0701275380000001</EndorsingBankItemSequenceNum>
    <TruncationIndicator>Y</TruncationIndicator>
    <EndorsingBankConversionInd>2</EndorsingBankConversionInd>
    <EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
    </CDC>
    <CDC num="2">
    <AddendumCRecordNumber>1</AddendumCRecordNumber>
    <EndorsingBankRountingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </EndorsingBankRountingNumber>
    <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
    <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
    <EndorsingBankItemSequenceNum>0701275380000002</EndorsingBankItemSequenceNum>
    <TruncationIndicator>Y</TruncationIndicator>
    <EndorsingBankConversionInd>2</EndorsingBankConversionInd>
    <EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
    </CDC>
    </CDC>
    <IVD>
    <IVD num="1">
    <ImageIndicator>1</ImageIndicator>
    <ImageCreatorRountingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ImageCreatorRountingNumber>
    <ImageCreatorDate>20090714</ImageCreatorDate>
    <ImageViewFormatIndicator>0</ImageViewFormatIndicator>
    <ImageViewCompressionAlg>0</ImageViewCompressionAlg>
    <ViewSideIndicator>0</ViewSideIndicator>
    <ViewDescriptor>0</ViewDescriptor>
    <DigitalSignatureIndicator>1</DigitalSignatureIndicator>
    <DigitalSignatureMethod>0</DigitalSignatureMethod>
    <SecurityKeySize>12235</SecurityKeySize>
    <ImageRecreateIndicator>0</ImageRecreateIndicator>
    </IVD>
    <IVD num="2">
    <ImageIndicator>1</ImageIndicator>
    <ImageCreatorRountingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ImageCreatorRountingNumber>
    <ImageCreatorDate>20090714</ImageCreatorDate>
    <ImageViewFormatIndicator>0</ImageViewFormatIndicator>
    <ImageViewCompressionAlg>0</ImageViewCompressionAlg>
    <ViewSideIndicator>0</ViewSideIndicator>
    <ViewDescriptor>0</ViewDescriptor>
    <DigitalSignatureIndicator>1</DigitalSignatureIndicator>
    <DigitalSignatureMethod>0</DigitalSignatureMethod>
    <SecurityKeySize>12235</SecurityKeySize>
    <ImageRecreateIndicator>0</ImageRecreateIndicator>
    </IVD>
    </IVD>
    <IVT>
    <IVT num="1">
    <ECEInstitutionRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ECEInstitutionRoutingNumber>
    <BundleBusinessDate>20090714</BundleBusinessDate>
    <CycleNumber>0</CycleNumber>
    <ECEInstitutionItemSeqNumber>0701275380000001</ECEInstitutionItemSeqNumber>
    <ClippingOrigin>
    <Origin>0</Origin>
    <CoordinateH1>0000</CoordinateH1>
    <CoordinateH2>0000</CoordinateH2>
    <CoordinateV1>0000</CoordinateV1>
    <CoordinateV2>0000</CoordinateV2>
    </ClippingOrigin>
    <LengthofImageReferenceKey>0</LengthofImageReferenceKey>
    <LengthofDigitalSignature>0</LengthofDigitalSignature>
    <LengthofImageData>1</LengthofImageData>
    <OffsetToImageData>01001000</OffsetToImageData>
    </IVT>
    <IVT num="2">
    <ECEInstitutionRoutingNumber>
    <BankCode>070</BankCode>
    <DistrictCode>12</DistrictCode>
    <BranchCode>75</BranchCode>
    <CheckDigit>8</CheckDigit>
    </ECEInstitutionRoutingNumber>
    <BundleBusinessDate>20090714</BundleBusinessDate>
    <CycleNumber>0</CycleNumber>
    <ECEInstitutionItemSeqNumber>0701275380000002</ECEInstitutionItemSeqNumber>
    <ClippingOrigin>
    <Origin>0</Origin>
    <CoordinateH1>0000</CoordinateH1>
    <CoordinateH2>0000</CoordinateH2>
    <CoordinateV1>0000</CoordinateV1>
    <CoordinateV2>0000</CoordinateV2>
    </ClippingOrigin>
    <LengthofImageReferenceKey>0</LengthofImageReferenceKey>
    <LengthofDigitalSignature>0</LengthofDigitalSignature>
    <LengthofImageData>1</LengthofImageData>
    <OffsetToImageData>01001000</OffsetToImageData>
    </IVT>
    </IVT>
    <IVA>
    <IVA num="1">
    <GlobalImageQuality>0</GlobalImageQuality>
    <GlobalImageUsability>1</GlobalImageUsability>
    <ImagingBankSpecificTest>1</ImagingBankSpecificTest>
    </IVA>
    <IVA num="2">
    <GlobalImageQuality>0</GlobalImageQuality>
    <GlobalImageUsability>1</GlobalImageUsability>
    <ImagingBankSpecificTest>1</ImagingBankSpecificTest>
    </IVA>
    </IVA>
    <BCR>
    <ItemsWithinBundleCount>2</ItemsWithinBundleCount>
    <BundleTotalAmount>1500</BundleTotalAmount>
    <MICRValidTotalAmount>1500</MICRValidTotalAmount>
    </BCR>
    </ForwardBundle>
    <CCR>
    <BundleCount>1</BundleCount>
    <ItemWithinCashLetterCount>2</ItemWithinCashLetterCount>
    <CashLetterTotalAmount>1500</CashLetterTotalAmount>
    <ImagesWithinCashLetterCount>2</ImagesWithinCashLetterCount>
    <ECEInstitutionName>Bank Asia</ECEInstitutionName>
    <SettlementDate>20090714</SettlementDate>
    </CCR>
    </Collection>
    <ECR>
    <CashLetterCount>1</CashLetterCount>
    <TotalRecordCount>2</TotalRecordCount>
    <TotalItemCount>2</TotalItemCount>
    <FileTotalAmount>1500</FileTotalAmount>
    <ImmediateOriginContactName>Bank Asia</ImmediateOriginContactName>
    <ImmediateOriginContactNumber>XXX</ImmediateOriginContactNumber>
    </ECR>
    </OCE>
    </BACPSInterface>'
    , BFILENAME('MY_INWARD','Outward.xml'));
    COMMIT;

    What version of Oracle (4 digits) and what is the error?
    This runs without error on 10.2.0.4 (though you can go directly from a CLOB to a DOMDocument via dbms_xmldom)
    -- Created on 9/14/2009 by JH20567
    declare
      -- Local variables here
      l_clob   CLOB;
      l_parser dbms_xmlparser.Parser;
      l_doc    dbms_xmldom.DOMDocument;
    begin
      -- Test statements here
       l_clob := '<?xml version="1.0" encoding="UTF-8"?>
    <BACPSInterface>
       <OCE>
          <EHR>
             <StandardLevel>03</StandardLevel>
             <TestFiledIndicator>T</TestFiledIndicator>
             <ImmediateDestRoutingNumber>
                <BankCode>070</BankCode>
                <DistrictCode>12</DistrictCode>
                <BranchCode>75</BranchCode>
                <CheckDigit>8</CheckDigit>
             </ImmediateDestRoutingNumber>
             <ImmediateOriginRoutingNumber>
                <BankCode>070</BankCode>
                <DistrictCode>12</DistrictCode>
                <BranchCode>75</BranchCode>
                <CheckDigit>8</CheckDigit>
             </ImmediateOriginRoutingNumber>
             <FileCreationDate>20090714</FileCreationDate>
             <FileCreationTime>1047</FileCreationTime>
             <ResendIndicator>N</ResendIndicator>
             <ECESettlementDate>20090714</ECESettlementDate>
             <ECESessionTime>1047</ECESessionTime>
             <ECESettlementTime>1047</ECESettlementTime>
             <ECEtype>01</ECEtype>
             <CountryCode>BD</CountryCode>
          </EHR>
          <Collection>
             <CHR>
                <CashLetterBusinessDate>20090714</CashLetterBusinessDate>
                <CashLetterCreationDate>20090714</CashLetterCreationDate>
                <CashLetterCreationTime>1047</CashLetterCreationTime>
                <CashLetterRecordTypeInd>I</CashLetterRecordTypeInd>
                <CashLetterDocTypeIndicator>G</CashLetterDocTypeIndicator>
                <CashLetterID>1</CashLetterID>
                <OriginatorContactName>Bank Asia</OriginatorContactName>
                <OriginatorContactPhoneNumber>XXX</OriginatorContactPhoneNumber>
             </CHR>
             <ForwardBundle>
                <BHR>
                   <CollectionTypeIndicator>I</CollectionTypeIndicator>
                   <DestRoutingNumber>
                      <BankCode>070</BankCode>
                      <DistrictCode>12</DistrictCode>
                      <BranchCode>75</BranchCode>
                      <CheckDigit>8</CheckDigit>
                   </DestRoutingNumber>
                   <ECEInstitutionRoutingNumber>
                      <BankCode>070</BankCode>
                      <DistrictCode>12</DistrictCode>
                      <BranchCode>75</BranchCode>
                      <CheckDigit>8</CheckDigit>
                   </ECEInstitutionRoutingNumber>
                   <BundleBusinessDate>20090714</BundleBusinessDate>
                   <BundleCreationDate>20090714</BundleCreationDate>
                   <BundleID>1</BundleID>
                   <ReturnLocationRoutingNumber>070127538</ReturnLocationRoutingNumber>
                </BHR>
                <CDR>
                   <CDR num="1">
                      <ECESettlementDate>20090714</ECESettlementDate>
                      <ECESessionTime>1047</ECESessionTime>
                      <ECESettlementTime>1047</ECESettlementTime>
                      <ECEItemType>N</ECEItemType>
                      <IssuingBranchRoutingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </IssuingBranchRoutingNumber>
                      <AccountNumber>0000334008221</AccountNumber>
                      <ChequeSequenceNumber>1601735</ChequeSequenceNumber>
                      <ItemAmount>500</ItemAmount>
                      <ECEInstitutionItemSequencNum>0701275380000001</ECEInstitutionItemSequencNum>
                      <DocumentationTypeIndicator>I</DocumentationTypeIndicator>
                      <ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
                      <MICRValidIndicator>1</MICRValidIndicator>
                      <BOFDIndicator>Y</BOFDIndicator>
                      <ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
                      <CorrectionIndicator>0</CorrectionIndicator>
                      <RepresentmentIndicator>0</RepresentmentIndicator>
                      <ArchiveTypeIndicator>F</ArchiveTypeIndicator>
                   </CDR>
                   <CDR num="2">
                      <ECESettlementDate>20090714</ECESettlementDate>
                      <ECESessionTime>1047</ECESessionTime>
                      <ECESettlementTime>1047</ECESettlementTime>
                      <ECEItemType>N</ECEItemType>
                      <IssuingBranchRoutingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </IssuingBranchRoutingNumber>
                      <AccountNumber>0000345682256</AccountNumber>
                      <ChequeSequenceNumber>1234567</ChequeSequenceNumber>
                      <ItemAmount>1000</ItemAmount>
                      <ECEInstitutionItemSequencNum>0701275380000002</ECEInstitutionItemSequencNum>
                      <DocumentationTypeIndicator>I</DocumentationTypeIndicator>
                      <ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
                      <MICRValidIndicator>1</MICRValidIndicator>
                      <BOFDIndicator>Y</BOFDIndicator>
                      <ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
                      <CorrectionIndicator>0</CorrectionIndicator>
                      <RepresentmentIndicator>0</RepresentmentIndicator>
                      <ArchiveTypeIndicator>F</ArchiveTypeIndicator>
                   </CDR>
                </CDR>
                <CDA>
                   <CDA num="1">
                      <AddendumRecordNumber>1</AddendumRecordNumber>
                      <BOFDRoutingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>75</DistrictCode>
                         <BranchCode>12</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </BOFDRoutingNumber>
                      <BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
                      <BOFDDepositAccountNumber>0000334008221</BOFDDepositAccountNumber>
                      <BOFDDepositBranch>753</BOFDDepositBranch>
                      <PayeeName>XXX</PayeeName>
                      <TruncationIndicator>Y</TruncationIndicator>
                      <BOFDConversionIndicator>2</BOFDConversionIndicator>
                      <BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
                   </CDA>
                   <CDA num="2">
                      <AddendumRecordNumber>1</AddendumRecordNumber>
                      <BOFDRoutingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>75</DistrictCode>
                         <BranchCode>12</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </BOFDRoutingNumber>
                      <BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
                      <BOFDDepositAccountNumber>0000345682256</BOFDDepositAccountNumber>
                      <BOFDDepositBranch>753</BOFDDepositBranch>
                      <PayeeName>XXX</PayeeName>
                      <TruncationIndicator>Y</TruncationIndicator>
                      <BOFDConversionIndicator>2</BOFDConversionIndicator>
                      <BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
                   </CDA>
                </CDA>
                <CDC>
                   <CDC num="1">
                      <AddendumCRecordNumber>1</AddendumCRecordNumber>
                      <EndorsingBankRountingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </EndorsingBankRountingNumber>
                      <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
                      <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
                      <EndorsingBankItemSequenceNum>0701275380000001</EndorsingBankItemSequenceNum>
                      <TruncationIndicator>Y</TruncationIndicator>
                      <EndorsingBankConversionInd>2</EndorsingBankConversionInd>
                      <EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
                   </CDC>
                   <CDC num="2">
                      <AddendumCRecordNumber>1</AddendumCRecordNumber>
                      <EndorsingBankRountingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </EndorsingBankRountingNumber>
                      <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
                      <EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
                      <EndorsingBankItemSequenceNum>0701275380000002</EndorsingBankItemSequenceNum>
                      <TruncationIndicator>Y</TruncationIndicator>
                      <EndorsingBankConversionInd>2</EndorsingBankConversionInd>
                      <EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
                   </CDC>
                </CDC>
                <IVD>
                   <IVD num="1">
                      <ImageIndicator>1</ImageIndicator>
                      <ImageCreatorRountingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </ImageCreatorRountingNumber>
                      <ImageCreatorDate>20090714</ImageCreatorDate>
                      <ImageViewFormatIndicator>0</ImageViewFormatIndicator>
                      <ImageViewCompressionAlg>0</ImageViewCompressionAlg>
                      <ViewSideIndicator>0</ViewSideIndicator>
                      <ViewDescriptor>0</ViewDescriptor>
                      <DigitalSignatureIndicator>1</DigitalSignatureIndicator>
                      <DigitalSignatureMethod>0</DigitalSignatureMethod>
                      <SecurityKeySize>12235</SecurityKeySize>
                      <ImageRecreateIndicator>0</ImageRecreateIndicator>
                   </IVD>
                   <IVD num="2">
                      <ImageIndicator>1</ImageIndicator>
                      <ImageCreatorRountingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </ImageCreatorRountingNumber>
                      <ImageCreatorDate>20090714</ImageCreatorDate>
                      <ImageViewFormatIndicator>0</ImageViewFormatIndicator>
                      <ImageViewCompressionAlg>0</ImageViewCompressionAlg>
                      <ViewSideIndicator>0</ViewSideIndicator>
                      <ViewDescriptor>0</ViewDescriptor>
                      <DigitalSignatureIndicator>1</DigitalSignatureIndicator>
                      <DigitalSignatureMethod>0</DigitalSignatureMethod>
                      <SecurityKeySize>12235</SecurityKeySize>
                      <ImageRecreateIndicator>0</ImageRecreateIndicator>
                   </IVD>
                </IVD>
                <IVT>
                   <IVT num="1">
                      <ECEInstitutionRoutingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </ECEInstitutionRoutingNumber>
                      <BundleBusinessDate>20090714</BundleBusinessDate>
                      <CycleNumber>0</CycleNumber>
                      <ECEInstitutionItemSeqNumber>0701275380000001</ECEInstitutionItemSeqNumber>
                      <ClippingOrigin>
                         <Origin>0</Origin>
                         <CoordinateH1>0000</CoordinateH1>
                         <CoordinateH2>0000</CoordinateH2>
                         <CoordinateV1>0000</CoordinateV1>
                         <CoordinateV2>0000</CoordinateV2>
                      </ClippingOrigin>
                      <LengthofImageReferenceKey>0</LengthofImageReferenceKey>
                      <LengthofDigitalSignature>0</LengthofDigitalSignature>
                      <LengthofImageData>1</LengthofImageData>
                      <OffsetToImageData>01001000</OffsetToImageData>
                   </IVT>
                   <IVT num="2">
                      <ECEInstitutionRoutingNumber>
                         <BankCode>070</BankCode>
                         <DistrictCode>12</DistrictCode>
                         <BranchCode>75</BranchCode>
                         <CheckDigit>8</CheckDigit>
                      </ECEInstitutionRoutingNumber>
                      <BundleBusinessDate>20090714</BundleBusinessDate>
                      <CycleNumber>0</CycleNumber>
                      <ECEInstitutionItemSeqNumber>0701275380000002</ECEInstitutionItemSeqNumber>
                      <ClippingOrigin>
                         <Origin>0</Origin>
                         <CoordinateH1>0000</CoordinateH1>
                         <CoordinateH2>0000</CoordinateH2>
                         <CoordinateV1>0000</CoordinateV1>
                         <CoordinateV2>0000</CoordinateV2>
                      </ClippingOrigin>
                      <LengthofImageReferenceKey>0</LengthofImageReferenceKey>
                      <LengthofDigitalSignature>0</LengthofDigitalSignature>
                      <LengthofImageData>1</LengthofImageData>
                      <OffsetToImageData>01001000</OffsetToImageData>
                   </IVT>
                </IVT>
                <IVA>
                   <IVA num="1">
                      <GlobalImageQuality>0</GlobalImageQuality>
                      <GlobalImageUsability>1</GlobalImageUsability>
                      <ImagingBankSpecificTest>1</ImagingBankSpecificTest>
                   </IVA>
                   <IVA num="2">
                      <GlobalImageQuality>0</GlobalImageQuality>
                      <GlobalImageUsability>1</GlobalImageUsability>
                      <ImagingBankSpecificTest>1</ImagingBankSpecificTest>
                   </IVA>
                </IVA>
                <BCR>
                   <ItemsWithinBundleCount>2</ItemsWithinBundleCount>
                   <BundleTotalAmount>1500</BundleTotalAmount>
                   <MICRValidTotalAmount>1500</MICRValidTotalAmount>
                </BCR>
             </ForwardBundle>
             <CCR>
                <BundleCount>1</BundleCount>
                <ItemWithinCashLetterCount>2</ItemWithinCashLetterCount>
                <CashLetterTotalAmount>1500</CashLetterTotalAmount>
                <ImagesWithinCashLetterCount>2</ImagesWithinCashLetterCount>
                <ECEInstitutionName>Bank Asia</ECEInstitutionName>
                <SettlementDate>20090714</SettlementDate>
             </CCR>
          </Collection>
          <ECR>
             <CashLetterCount>1</CashLetterCount>
             <TotalRecordCount>2</TotalRecordCount>
             <TotalItemCount>2</TotalItemCount>
             <FileTotalAmount>1500</FileTotalAmount>
                   <ImmediateOriginContactName>Bank Asia</ImmediateOriginContactName>
                   <ImmediateOriginContactNumber>XXX</ImmediateOriginContactNumber>
              </ECR>
         </OCE>
    </BACPSInterface>';
       l_parser := dbms_xmlparser.newParser;
       dbms_xmlparser.parseClob(l_parser, l_clob);
       l_doc := dbms_xmlparser.getDocument(l_parser);
       dbms_lob.freetemporary(l_clob);
       dbms_xmlparser.freeParser(l_parser); 
       dbms_xmldom.freeDocument(l_doc);
    end;

  • Storing XML data in CLOB and relational tables

    I would like to ask whether there is a possibility to store XML data using normal relational tables and CLOBs in the same time. For example I have some XML data (structured data) which I would like update very often and some which are only a kind of description. I found something about it in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm . But I do not know how to use Oracle8i views and some functionality of XML SQL Utility to retrieve XML data in one file.
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Maciej Marczukajtis ([email protected]):
    I would like to ask whether there is a possibility to store XML data using normal relational tables and CLOBs in the same time. For example I have some XML data (structured data) which I would like update very often and some which are only a kind of description. I found something about it in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm . But I do not know how to use Oracle8i views and some functionality of XML SQL Utility to retrieve XML data in one file.<HR></BLOCKQUOTE>
    Czesc Maciek,
    There are some good examples with XSQL Servlet. From what I understand you have one XML file and you need to save a portion of document in relational tables and other portion in CLOB.
    Yes, you can do that.
    You can do it many ways. I can suggest (2).
    1. Use the views
    2. call your java procedure that will do
    the xml processing, brake it down and insert
    releval frogments into different tables/columns
    null

  • Query to read XML from CLOB table column

    Hi
    I want an SQL to get the following information extract from a CLOB table column.
    MasterReport/sg:RptDef/sg:RptCell@RealDesc MasterReport/sg:RptDef/sg:RptCell@RealNum
    credits                              100
    debits                              100
    Sample XML data from table column is:
    <?xml version="1.0" encoding="UTF-8" ?>
    <MasterReport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sg="http://www.oracle.com/fsg/2002-03-20/" xsi:schemaLocation="http://www.oracle.com/2002-03-20/fsg.xsd">
    <sg:LDGName>Vision Portugal</sg:LDGName>
    <sg:SOBName>Vision Portugal</sg:SOBName>
    <sg:DataAccessSetName>Vision Portugal</sg:DataAccessSetName>
    <sg:InternalReportName>Model 30 Report</sg:InternalReportName>
    <sg:CustomParam10 />
    <sg:RowContext RowId="r100001">
    <sg:RowName />
    <sg:RowLineItem>Litigation Credits- Total amount from previous period</sg:RowLineItem>
    <sg:RowDispUnit>1</sg:RowDispUnit>
    <sg:RowDispFormat />
    <sg:RowUnitOfMeasure>EUR</sg:RowUnitOfMeasure>
    <sg:RowLedgerCurrency>ANY</sg:RowLedgerCurrency>
    <sg:RowCurrencyType>T</sg:RowCurrencyType>
    <sg:RowChangeSign>0</sg:RowChangeSign>
    <sg:RowSeq>1.0000000000000</sg:RowSeq>
    </sg:RowContext>
    <sg:RowContext RowId="r100002">
    <sg:RowName />
    <sg:RowLineItem>Litigation credits- Taxed amounts from column2 for Previous period</sg:RowLineItem>
    <sg:RowDispUnit>1</sg:RowDispUnit>
    <sg:RowDispFormat />
    <sg:RowUnitOfMeasure>EUR</sg:RowUnitOfMeasure>
    <sg:RowLedgerCurrency>ANY</sg:RowLedgerCurrency>
    <sg:RowCurrencyType>T</sg:RowCurrencyType>
    <sg:RowChangeSign>0</sg:RowChangeSign>
    <sg:RowSeq>2.0000000000000</sg:RowSeq>
    </sg:RowContext>
    <sg:ColContext ColId="c1000">
    <sg:ColAmountType />
    <sg:ColPeriod />
    <sg:ColPerOffset />
    <sg:ColChangeSign />
    <sg:ColPosition />
    <sg:ColSeq />
    <sg:ColWidth>100</sg:ColWidth>
    </sg:ColContext>
    <sg:ColContext ColId="c1001">
    <sg:ColName>Total</sg:ColName>
    <sg:ColDescr />
    <sg:ColDispUnit>1</sg:ColDispUnit>
    <sg:ColUnitOfMeasure>EUR</sg:ColUnitOfMeasure>
    <sg:ColLedgerCurrency>ANY</sg:ColLedgerCurrency>
    <sg:ColCurrencyType>T</sg:ColCurrencyType>
    <sg:ColDispFormat>999999999.99</sg:ColDispFormat>
    <sg:ColAmountType>YTD-Actual</sg:ColAmountType>
    <sg:ColPerOffset>0</sg:ColPerOffset>
    <sg:ColAmntId>14</sg:ColAmntId>
    <sg:ColParamId>-1</sg:ColParamId>
    <sg:ColType>A</sg:ColType>
    <sg:ColStyle>B</sg:ColStyle>
    <sg:ColPeriod>10-08</sg:ColPeriod>
    <sg:ColPeriodYear>2008</sg:ColPeriodYear>
    <sg:ColPeriodNum>11</sg:ColPeriodNum>
    <sg:ColPeriodStart>2008-10-01T00:00:00</sg:ColPeriodStart>
    <sg:ColPeriodEnd>2008-10-31T00:00:00</sg:ColPeriodEnd>
    <sg:ColChangeSign>0</sg:ColChangeSign>
    <sg:ColHeadLine1>Totals</sg:ColHeadLine1>
    <sg:ColHeadLine2 />
    <sg:ColHeadLine3 />
    <sg:ColHeadLine4 />
    <sg:ColHeadLine5 />
    <sg:ColHeadLine6 />
    <sg:ColHeadLine7 />
    <sg:ColHeadLine8 />
    <sg:ColHeadLine9 />
    <sg:ColPosition>99</sg:ColPosition>
    <sg:ColSeq>1.0000000000000</sg:ColSeq>
    <sg:ColWidth>14</sg:ColWidth>
    </sg:ColContext>
    <sg:RptDef RptId="p1001" RptDetName="Ledger=Vision PT (Vision Portugal)" RptPESegm="" RptPEVal="" RptTabLabel="Output 1 (Vision PT)">
    <sg:RptLine RptCnt="p1001" RowCnt="r100001" LineRowSeq="1.0000000000000" LinCnt="l100001">
    <sg:RptCell ColCnt="c1000" RealDesc="debits">debits</sg:RptCell>
    <sg:RptCell ColCnt="c1001" RealNum="100.000000">100.00</sg:RptCell>
    </sg:RptLine>
    <sg:RptLine RptCnt="p1001" RowCnt="r100002" LineRowSeq="2.0000000000000" LinCnt="l100002">
    <sg:RptCell ColCnt="c1000" RealDesc="creditsd">credits</sg:RptCell>
    <sg:RptCell ColCnt="c1001" RealNum="100.000000">100.00</sg:RptCell>
    </sg:RptLine>
    </sg:RptDef>
    <sg:TabCount>1</sg:TabCount>
    </MasterReport>
    Please help me.
    Regards
    Giri
    Edited by: user576087 on Mar 18, 2012 11:54 PM

    I'm not sure if you want the values from the attribute or the element, but this should give you a good start :
    SQL> alter session set nls_numeric_characters = ".,";
    Session altered
    SQL>
    SQL> select x.*
      2  from my_table t
      3     , xmltable(
      4         xmlnamespaces('http://www.oracle.com/fsg/2002-03-20/' as "sg")
      5       , '/MasterReport/sg:RptDef/sg:RptLine'
      6         passing xmltype(t.xmldoc)
      7         columns type    varchar2(30) path 'sg:RptCell[1]'
      8               , amount  number       path 'sg:RptCell[2]'
      9       ) x
    10  ;
    TYPE                               AMOUNT
    debits                                100
    credits                               100

  • How to read XML data stored in CLOB in Concurrent prog Output

    Hi All,
    I'm trying to Generate the XML Data as concurrent Program output. I have a PL/SQL package which generated the XML data by using SQL/XML functions. I'm storing the generated XML data in a CLOB variable. But when i try to read the data using fnd_file.put_line(fnd_file.OUTPUT,XML_Data) it doesn't display data more than 32767 bytes.
    Please help me out to understand what could be done to read the data in chunks. I have tried many logic's to print chunks of data but the output tags are either chopped off and errors out saying Tag not found.
    My logic is as below:
    v_handler:= DBMS_XMLGEN.newContext(v_xml_query);
    --Sets NULL handling options
    DBMS_XMLGen.SetNullHandling(v_handler, dbms_xmlgen.EMPTY_TAG ) ;
    --Set special character handling
    DBMS_XMLGEN.setConvertSpecialChars(v_handler, TRUE);
    -- Specified whether to use an XML attribute to indicate NULLness of particular entity in the XML document
    DBMS_XMLGen.useNullAttributeIndicator(v_handler,TRUE);
    -- set Checking invalid chars
    DBMS_XMLGEN.setCheckInvalidChars(v_handler, TRUE);
    -- get the xml data as required
    v_xml_data:= DBMS_XMLGEN.getXMLtype(v_handler);
    SELECT XMLROOT(v_xml_data.extract('/*'),VERSION '1.0').getClobVal() into v_new_xml_Data from dual;
    -- get the length of the xml generated
    v_clob_len := dbms_lob.getlength(v_new_xml_Data);
    FND_FILE.PUT_LINE(FND_FILE.LOG,'The Clob length is :'|| v_clob_len);
    -- logic to process string more than 32767 Processing by each character
    v_offset :=1;
    while (v_offset <= v_clob_len)
    LOOP
    v_char := dbms_lob.substr(v_new_xml_Data, 1, v_offset);
    IF (v_char = CHR(10))
    then
    fnd_file.new_line(fnd_file.output, 1);
    else
    fnd_file.put(fnd_file.output, v_char);
    end if;
    v_offset := v_offset + 1;
    END LOOP;
    FND_FILE.PUT_LINE(FND_FILE.LOG,'The offset is :'|| v_offset);
    FND_FILE.NEW_LINE(FND_FILE.OUTPUT, 1);
    THe above logic is for character by character which is a performance burden? Please let me know if there is any other work around for this

    Hi,
    Thanks for Replying. I have refered http://blog.oraclecontractors.com/?p=69 and then i added that piece of code. Basically, i'm trying to generate a report using XML publisher. To generate the XML data i'm writing a pl/sql package with SQl/XML functions. DBMS_XMLGEN would help me convert the XML Data as is. When the concurrent program runs this XML data will merge with RTF layout and generate required report. I'm able to generate the Report for data less then 32767 bytes. More than the limit i need to pass chunks of XML data to read as output. That's the reason i'm using fnd_file.output. But it reads only 32767 size at a time.
    WHen i use the given logic, it works perfectly fine, but it loops for each character, for example if you have 30,000 characters it loops the same, which is peformance burden.
    So i tried to write the logic of chunks but still i get the error that XML tag is not found or missing. I'm hoping this is very common issue, but after all my trails, i didn't find the right solution.
    the other logic i tried was :
    v_new_xml_data varchar2(32767)
    v_iterations := CEIL(v_clob_len/v_chunk_length); -- v_chunk_length is 32767 and v_clob_length is length of the XML data stored inthe clob variable
    For i in 0..v_iterations
    LOOP
    FND_FILE.put_line (fnd_file.log,'the loops v_pos :'||i||' and v_clob_length :'||v_clob_len);
    v_new_xml_data := DBMS_LOB.SUBSTR ( V_XML_DATA,v_chunk_length,(i*v_chunk_length)+1);
    FND_FILE.PUT_LINE (FND_FILE.OUTPUT,v_new_xml_data); -- read the output for every 32767 chunks
    FND_FILE.PUT_LINE(FND_FILE.LOG, 'Chunk length is :'||((i*v_chunk_length)+1));
    END LOOP;
    FND_FILE.put_line (fnd_file.log,'out of loop');
    FND_FILE.put_line (fnd_file.log,'length of new xml is '||v_clob_len);
    Please, let me know if you need Further clarifications on the same.

  • Reading Xml file from clob column in the staging table

    Hi,
    I am trying to poll the staging table with the database adapter which has CLOB column type containing XML file. How do I extract the XML file from CLOB and map the fields to the another variable with definite schema.
    Thanks,
    Edited by: chaitu123 on Sep 20, 2009 8:16 AM

    1) when you create DBAdapter on a table which having the clob column watch closely the created xsd for the DBAdapter the clob cloumn element should be a String data type
    2) create xsd for Xml File and create variable for the xsd element
    3) use ora:parseEscapedXML("yourDBAdapterclobElement") to XmlFileVarilable
    Krishna

  • Fetch XML data stored in database table column dynamically

    Hi All,
    I am working as a SQL guy but never worked on XML in SQlbefore.
    During some project work , we need to fetch value from xml stored in database column.
    Problem is rowsof xml column arebit different and have different values.
    Could anybody help me to build something dynamic to fetch all values from each row .
    My data look like:
    TEXT
    <
    RiskEndorsement><ExistingExposureSplitLimitsChange><NewRiskLimitSeq>536504</NewRiskLimitSeq><EffDate>11/1/2011</EffDate></ExistingExposureSplitLimitsChange></RiskEndorsement>
    <
    RiskEndorsement><MandatoryStateRateSplit><StateCode>NY</StateCode><EffDate>4/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement>
    <
    RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197608</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.890</ExModFactor><SplitDate>3/11/2012</SplitDate></NonAnniversaryExModSplit></RiskEndorsement>
    <
    RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197613</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.970</ExModFactor><SplitDate>1/13/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement>
    <
    RiskEndorsement><MandatoryStateRateSplit><StateCode>AL</StateCode><EffDate>7/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement>
    <
    RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>208975</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>230094357</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.8700</ExModFactor><SplitDate>1/1/2012</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement>
    <
    RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213467</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>2431638</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.6800</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement>
    <
    RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>213473</RiskBureauSeq><RiskIDStatusSeq>1615</RiskIDStatusSeq><RiskIDNbr>917661014</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.860</ExModFactor><SplitDate>10/1/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement>
    <
    RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213497</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>1146456</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.830</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement>
    Andrew

    Please post a concise and complete example. Include table DDL and sample data INSERT statements.
    Cause the solution depends on your actual structure. Otherwise take a look at the
    nodes() method.
    E.g.
    DECLARE @Sample TABLE
    ID INT IDENTITY ,
    Data XML
    INSERT INTO @Sample
    ( Data )
    VALUES ( '<RiskEndorsement><ExistingExposureSplitLimitsChange><NewRiskLimitSeq>536504</NewRiskLimitSeq><EffDate>11/1/2011</EffDate></ExistingExposureSplitLimitsChange></RiskEndorsement> ' ),
    ( '<RiskEndorsement><MandatoryStateRateSplit><StateCode>NY</StateCode><EffDate>4/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197608</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.890</ExModFactor><SplitDate>3/11/2012</SplitDate></NonAnniversaryExModSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197613</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.970</ExModFactor><SplitDate>1/13/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><MandatoryStateRateSplit><StateCode>AL</StateCode><EffDate>7/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>208975</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>230094357</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.8700</ExModFactor><SplitDate>1/1/2012</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213467</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>2431638</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.6800</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>213473</RiskBureauSeq><RiskIDStatusSeq>1615</RiskIDStatusSeq><RiskIDNbr>917661014</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.860</ExModFactor><SplitDate>10/1/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement> ' ),
    ( '<RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213497</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>1146456</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.830</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement> ' );
    SELECT ID ,
    ExistingExposureSplitLimitsChange.value('NewRiskLimitSeq[1]', 'INT') AS NewRiskLimitSeq ,
    ExistingExposureSplitLimitsChange.value('EffDate[1]', 'DATE') AS EffDate
    FROM @Sample S
    CROSS APPLY S.Data.nodes('/RiskEndorsement/ExistingExposureSplitLimitsChange') A ( ExistingExposureSplitLimitsChange );
    SELECT ID ,
    MandatoryStateRateSplit.value('StateCode[1]', 'NVARCHAR(255)') AS StateCode ,
    MandatoryStateRateSplit.value('EffDate[1]', 'DATE') AS EffDate
    FROM @Sample S
    CROSS APPLY S.Data.nodes('/RiskEndorsement/MandatoryStateRateSplit') A ( MandatoryStateRateSplit );
    SELECT ID ,
    NonAnniversaryExModSplit.value('RiskBureauSeq[1]', 'INT') AS RiskBureauSeq ,
    NonAnniversaryExModSplit.value('RiskIDStatusSeq[1]', 'INT') AS RiskIDStatusSeq ,
    NonAnniversaryExModSplit.value('RiskIDNbr[1]', 'INT') AS RiskIDNbr ,
    NonAnniversaryExModSplit.value('ExModStatusSeq[1]', 'INT') AS ExModStatusSeq ,
    NonAnniversaryExModSplit.value('ExModFactor[1]', 'FLOAT') AS ExModFactor ,
    NonAnniversaryExModSplit.value('SplitDate[1]', 'NVARCHAR(255)') AS SplitDateText
    FROM @Sample S
    CROSS APPLY S.Data.nodes('/RiskEndorsement/NonAnniversaryExModSplit') A ( NonAnniversaryExModSplit );
    SELECT ID ,
    AnniversaryRatingDateSplit.value('RiskBureauSeq[1]', 'INT') AS RiskBureauSeq ,
    AnniversaryRatingDateSplit.value('RiskIDStatusSeq[1]', 'INT') AS RiskIDStatusSeq ,
    AnniversaryRatingDateSplit.value('RiskIDNbr[1]', 'INT') AS RiskIDNbr ,
    AnniversaryRatingDateSplit.value('ExModStatusSeq[1]', 'INT') AS ExModStatusSeq ,
    AnniversaryRatingDateSplit.value('ExModFactor[1]', 'FLOAT') AS ExModFactor ,
    AnniversaryRatingDateSplit.value('SplitDate[1]', 'NVARCHAR(255)') AS SplitDateText
    FROM @Sample S
    CROSS APPLY S.Data.nodes('/RiskEndorsement/AnniversaryRatingDateSplit') A ( AnniversaryRatingDateSplit );

Maybe you are looking for