Extract the value of the XML column.

Hello

I'm on 11.2.0.3 and got query
select other_xml from v$sql_plan where sql_id=’2y32qkr40b82a’ and other_xml is not null

<other_xml><info type="db_version">11.2.0.3</info>
<info type="parse_schema"><![CDATA["LIU"]]></info><info type="dynamic_sampling">2</info>
<info type="plan_hash">3882242470</info><info type="plan_hash_2">281948136</info>
<peeked_binds><bind nam=":N1" pos="1" dty="2" pre="0" scl="0" mxl="22">c30d51</bind>
<bind nam=":N2" pos="2" dty="2" pre="0" scl="0" mxl="22">c30d51</bind>
<bind nam=":N3" pos="3" dty="2" pre="0" scl="0" mxl="22">c30d51</bind></peeked_binds>
<outline_data><hint><![CDATA[IGNORE_OPTIM_EMBEDDED_HINTS]]></hint>
<hint><![CDATA[OPTIMIZER_FEATURES_ENABLE('11.2.0.3')]]></hint>
<hint><![CDATA[DB_VERSION('11.2.0.3')]]></hint>
<hint><![CDATA[FIRST_ROWS(100)]]></hint>
<hint><![CDATA[OUTLINE_LEAF(@"SEL$1")]]></hint>
<hint><![CDATA[FULL(@"SEL$1" "LIU"@"SEL$1")]]></hint>
</outline_data></other_xml>
I want to output associated to < type info = "dynamic_sampling" > 2 < / info >:

dynamic_sampling of name of column
value of line 2

reflection by using dynamic_sampling value as a predicate would be great if:

Select * from v$ sql_plan
where
dynamic_sampling = 2

How to transform the other_xml column to get such results?


Concerning
GregG

Published by: GregG on February 8, 2013 13:14

XMLTABLE is a better way to do it as EXTRACTVALUE is obsolete but:

select p.sql_id,  extractvalue(h.column_value,'/info') lvl
from   v$sql_plan p
,      table(xmlsequence(extract(xmltype(p.other_xml),'/other_xml/info'))) h
where  p.other_xml is not null
and    extractvalue(h.column_value,'/info/@type') = 'dynamic_sampling';

11.1 I think the tag can say 'yes' rather than giving level.
If there is no dynamic sampling, there should be no tag dynamic sampling.

Tags: Database

Similar Questions

  • How to extract a value of sql xml column clob data

    Hi guys,.

    I need help with the following. I have a column with data type xml (clob data). I need to extract the information in the < RI4 > tag and the < RI6 > tag.
    I truncated the data, but there is a repetition of the < RI4 > tag and consequenty internal to that tag RI6. However, each tag RI4 and RI6 has different data.

    I would be grateful if you can help me with this:

    <a xsi:schemaLocation="som location.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:somlocation">
      <b>Some stuff here</b>
      <c>
      <someinfo>blah</someinfo>
      <someinfo2>blah2</someinfo2>
      </c>
      <EffectiveDateTime>2015-10-01T00:00:00+10:00</EffectiveDateTime>
      <CurrencyCode>AUD</CurrencyCode>
      <RequiredInformation>
      <RequiredInformation2>
      <RequiredInformation3>
      <RI4>someinfo</RI4>
      <RI5>
      <RI6>
      <a1>1</a1>
      <b1>9.13</b1>
      </RI6>
      <RI6>
      <a1>2</a1>
      <b1>8.75</b1>
      </RI6>
      <RI6>
      <a1>3</a1>
      <b1>78.90</b1>
      </RI6>
      <RI6>
      <a1>4</a1>
      <b1>200</b1>
      </RI6>
      <RI6>
      <a1>5</a1>
      <b1>17.59</b1>
      </RI6>
      </RI5>
      </RequiredInformation3>
      </RequiredInformation2>
      </RequiredInformation>
      </a>
    

    I think that since it's the repetition I might need to make some sort of PL/SQL programming, but I really need help here to build this announcement also a way to extract the information.

    Any help would be greatly appreciated.

    Kind regards

    You can parse your XML like this

    SQL> with t
      2  as
      3  (
      4  select
      5  '
      6      Some stuff here
      7      
      8          blah
      9          blah2
     10      
     11      2015-10-01T00:00:00+10:00
     12      AUD
     13      
     14          
     15              
     16                  someinfo
     17                  
     18                      
     19                          1
     20                          9.13
     21                      
     22                      
     23                          2
     24                          8.75
     25                      
     26                      
     27                          3
     28                          78.90
     29                      
     30                      
     31                          4
     32                          200
     33                      
     34                      
     35                          5
     36                          17.59
     37                      
     38                  
     39              
     40          
     41      
     42  ' xml_str
     43    from dual
     44   )
     45  select t1.ri4, t2.a1, t2.b1
     46    from t
     47       , xmltable
     48         (
     49            xmlnamespaces(default 'urn:somlocation', 'http://www.w3.org/2001/XMLSchema-instance' as "xsi")
     50         ,  '/a/RequiredInformation/RequiredInformation2/RequiredInformation3' passing xmltype(t.xml_str)
     51            columns
     52               ri4 varchar2(10) path 'RI4'
     53             , ri5 xmltype path 'RI5'
     54         ) t1
     55       , xmltable
     56         (
     57            xmlnamespaces(default 'urn:somlocation')
     58          , '/RI5/RI6' passing t1.ri5
     59            columns
     60               a1 number path 'a1'
     61             , b1 number path 'b1'
     62         ) t2;
    
    RI4                A1         B1
    ---------- ---------- ----------
    someinfo            1       9.13
    someinfo            2       8.75
    someinfo            3       78.9
    someinfo            4        200
    someinfo            5      17.59
    
    SQL>
    
  • Validate the XML column when inserting

    Hello

    I'm on 11 GR 2.

    I have a table

    create table root_table (id number, text xmltype);

    I tried to sign up:

    Start

    dbms_xmlschema.registerSchema ('test', xmltype)

    "' < xs: schema xmlns: XS ="http://www.w3.org/2001/XMLSchema"xmlns:xdb ="http://xmlns.oracle.com"elementFormDefault ="unqualified">

    < name XS: complexType 'RootType' = >

    < xs: SEQUENCE >

    < xs: element name = "Required" / >

    < xs: element name = "Énumération" >

    < xs:simpleType >

    < xs:restriction base = "XS: String" >

    < xs:enumeration value = 'A' / >

    < xs:enumeration value = 'B' / >

    < xs:enumeration value = 'C' / >

    < / xs:restriction >

    < / xs:simpleType >

    < / xs: element >

    < xs: element name = "MinLength" >

    < xs:simpleType >

    < xs:restriction base = "XS: String" >

    < xs:minLength value = "4" / >

    < xs:maxLength value = "20" / >

    < / xs:restriction >

    < / xs:simpleType >

    < / xs: element >

    < xs: element name = "MaxLength" >

    < xs:simpleType >

    < xs:restriction base = "XS: String" >

    < xs:minLength value = "1" / >

    < xs:maxLength value = "4" / >

    < / xs:restriction >

    < / xs:simpleType >

    < / xs: element >

    < xs: element name = "MaxOccurs" type = "xs: String" maxOccurs = "2" / >

    < xs: element name = "MinOccurs" minOccurs = '2' maxOccurs = "2" / >

    < xs: element name = "Optional" type = "xs: String" minOccurs = "0" / >

    < / xs: SEQUENCE >

    < / xs: complexType >

    < xs: element name = "root" type = "RootType" xdb:defaultTable = "ROOT_TABLE" / >

    ((< / xs: Schema > '));

    end;

    /

    table should point to the table where the XML column is default, I guess that

    is the 'root' in the same line a reference to the name of the xmltype column?

    Now - how do I ensure the XML I have insert in the column "change" is validated against the schema above?

    concerning

    Mette


    For both options, save the diagram with these options (you can substitute the url of course):

    Start

    () dbms_xmlschema.registerSchema

    schemaURL-online "test.xsd.

    schemaDoc-online xmltype (bfilename ('TEST_DIR', 'test.xsd'), 873)

    local-online true

    genTypes-online fake

    genTables-online fake

    enableHierarchy-online dbms_xmlschema. ENABLE_HIERARCHY_NONE

    options-online dbms_xmlschema. REGISTER_BINARYXML

    );

    end;

    /

    Then the #1 option:

    create table root_table)

    Identification number

    text xmltype

    )

    XMLType column can store as xml binary securefile

    XmlSchema 'test.xsd' element 'root '.

    ;

    SQL > insert into root_table values (1,

    2 xmlparse (document

    3'

    4

    5    A

    6 XXXX

    7 12345

    8

    9

    10

    11  ')

    (12);

    insert into root_table values (1,

    *

    ERROR on line 1:

    ORA-31061: error XDB: XML error event

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

    LSX-00222: "12345" is too long (maximum is 4)

    SQL >

    SQL > insert into root_table values (1,

    2 xmlparse (document

    3'

    4

    5    A

    6 XXXX

    7 1234

    8

    9

    10

    11 ')

    (12);

    insert into root_table values (1,

    *

    ERROR on line 1:

    ORA-31061: error XDB: XML error event

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

    LSX-00213: only 1 occurrences of the 'MinOccurs' particle, the minimum is 2

    SQL > insert into root_table values (1,

    2 xmlparse (document

    3'

    4

    5    D

    6 XXXX

    7 1234

    8

    9

    10

    11

    12  ')

    (13);

    insert into root_table values (1,

    *

    ERROR on line 1:

    ORA-31061: error XDB: XML error event

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

    LSX-00290: invalid enumeration choice "D".

    SQL > insert into root_table values (1,

    2 xmlparse (document

    3'

    4

    5    A

    6 XXXX

    7 1234

    8

    9

    10

    11

    12  ')

    (13);

    1 line of creation.

    For the #2 option:

    create table root_table2)

    Identification number

    text xmltype

    )

    XMLType column can store it as clob securefile

    ;

    create or replace trigger root_table2_biu_t

    before the insert or update

    on root_table2

    for each line

    declare

    doc xmltype: =: new.tekst.createSchemaBasedXML ('test.xsd');

    Start

    doc.schemaValidate ();

    end;

    /

    SQL > insert into root_table2 values (1,

    2 xmlparse (document

    3'

    4

    5    D

    6 XXXX

    7 1234

    8

    9

    10

    11

    12  ')

    (13);

    insert into root_table2 values (1,

    *

    ERROR on line 1:

    ORA-31154: invalid XML document

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

    LSX-00290: invalid enumeration choice "D".

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

    ORA-06512: at DEV. "" ROOT_TABLE2_BIU_T ", line 4

    ORA-04088: error during execution of trigger ' DEV. ROOT_TABLE2_BIU_T'

    Both options will perform a validation of strict type.

    There are other possible configurations, such as CLOB based on a storage schema, but this approach is now obsolete.

    If you are only interested in whether the XML instance is valid or not, you can also use a constraint check with the XMLisValid function.

  • the value of the xml column type tag data BLOB

    Hello

    I'm on Oracle 10 g.
    I have a table that has a column as BLOB data type and contains XML data. I need to select specific table records according to a unique tag value of the xml data in the BLOB column. For example:
    The table say Test has two columns: id (integer) and MESG (BLOB)
    The xml in the MESG column message is assumed:
    < message >
    < > 123456 contactphone < / contactphone >
    < contactname > ABCD < / contactname >
    < amount > 9999 < / amount >
    < / message >

    I need to extract only the records where the amount is = 9999

    Help, please. Thanks in advance.

    user12850338 wrote:
    Hi BluShadow,
    Thanks for your reply.
    I confess that if we would have used type xml in the first place, things would have been easier.
    For example, I mentioned three tags in the xml file, but my real data contains some hundreds of tags... :( So it will always be a good idea with this approach.

    Yes, it's a good approach. Oracle has provided built-in XML functionality to manage XML, then of course it's the best thing to use. :)

    For example, you can easily deal with namespaces and repeating nested groups and flatten the data in a table structure. for example

    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH t as (select XMLTYPE('
      2  
      3    
      4      1
      5      1800
      6      
      7        1
      8        28
      9        6
     10        12
     11      
     12      
     13        5
     14        19
     15        1
     16        90
     17      
     18    
     19    
     20      2
     21      2400
     22      
     23        3
     24        14
     25        7
     26        5
     27      
     28    
     29  ') as xml from dual)
     30  -- END OF TEST DATA
     31  select x.country, x.point, y.user_id, y.target, y.state, y.task
     32  from t
     33      ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
     34                '/RECSET/aa:REC'
     35                PASSING t.xml
     36                COLUMNS country NUMBER PATH '/aa:REC/aa:COUNTRY'
     37                       ,point   NUMBER PATH '/aa:REC/aa:POINT'
     38                       ,user_info XMLTYPE PATH '/aa:REC/*'
     39               ) x
     40      ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
     41                '/aa:USER_INFO'
     42                PASSING x.user_info
     43                COLUMNS user_id NUMBER PATH '/aa:USER_INFO/aa:USER_ID'
     44                       ,target  NUMBER PATH '/aa:USER_INFO/aa:TARGET'
     45                       ,state   NUMBER PATH '/aa:USER_INFO/aa:STATE'
     46                       ,task    NUMBER PATH '/aa:USER_INFO/aa:TASK'
     47*              ) y
    SQL> /
    
       COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
    ---------- ---------- ---------- ---------- ---------- ----------
             1       1800          1         28          6         12
             1       1800          5         19          1         90
             2       2400          3         14          7          5
    
    SQL>
    
  • Extract the XML tags and insert into the table

    Description:

    XML is under inert atmosphere in the table containing the xmltype column. Need to extract value from xml tag and insert into the table.
    Once the XML record Treaty must update the status as 'Y' in the base table

    Problem:
    There are multiple occurrences of some tags that need to be combined and stored in a single column to delineate the '-'. No. area of occurrence can vary for each record.
    There are a few encrypted column that I managed to convert decoded value. But used select distinct... XMLTYPE...
    GTT table is used to store the intermediate result and decoding and the concatenation of several tags occurred using TWG.

    1.No. multiple tag will vary how to extract those and concatenate them into a single column. I assumed his occrrence in 3 for example: < student >
    2. how to set the value NULL if no tag is not present. Tag in XML record number can vary. I know that the complete list of xmltags.
    3 data not found error for some xml documents.

    Kindly Assits how to achieve this.

    version: 11.2.0.3.0

    Table Base: temp_XML

    XML_ID NOT NULL NUMBER (28) - auto-increment using the sequence
    PUBLIC EVENT. Stores the XMLTYPE STORAGE BINARY - XML file
    DATE OF EVTDATE
    STATUS VARCHAR2 (3) DEFAULT ' don't

    Sample XML: Includes all the brands mentioned in the common procedure below.

    <? XML version = "1.0" encoding = "US-ASCII"? >

    "< event xmlns ="http://xmlextrac.test.com/object">."

    < data xmlns = "" >

    < object >

    <>units

    < unit > TLAS < / unit >

    < unit > ATLAS < / unit >

    < / units >

    < receiverNetworks >

    < receiverNetwork > ABSAZAJ0XXXX < / receiverNetwork >

    < / receiverNetworks >

    < correspondentIds >

    < correspondentId > #SWF - ABSAZAJ0XXX < / correspondentId >

    < / correspondentIds >

    < comment >

    < comment / >

    < comment / >

    < comment / >

    < comment / >

    < / comment >

    < memo >

    < memo > 28 < / memo >

    < / memos >

    < tuxedoPriority > 20 < / tuxedoPriority >

    sender <>Mike < / sender >

    < typeReseauId > Message < / typeReseauId >

    < maxRetry > 4 < / maxRetry >

    < msgSecuLevel > CBA < / msgSecuLevel >

    < quantity >

    < amount > 12 < / amount >

    < amount > 34 < / amount >

    < amount > 56 < / amount >

    < / amounts >

    < currencys >

    < currency > $ < / currency >

    < currency > EUR < / currency >

    INR < currency > < / currency >

    < / currencys >

    < msgDateVal > ARST123 < / msgDateVal >

    wder < direction > < / direction >

    < eventType > 113 < / eventType >

    < date > 1407431619 < / date >

    < eventDate > 1407431624 < / eventDate >

    < management > R < / direction >

    < msgRef > R950140807AB6CBE < / msgRef >

    < format > SWF < / size >

    < type > 950 < / type >

    R950140807AB6CBE < WALL > < / WALL >

    < bankingPriority / >

    FSDS < field.20 > < / field.20 >

    < texteType > FSS < / texteType >

    < applicationCode > OHS < / applicationCode >

    < company > KETH < / company >

    < endFct > MOE < / endFct >

    < rate > BAM < / flow >

    < subtype / >

    < text > DQo6MjA6R0wxNDA4MDcwMDA1MTMNCjoyNTo3M == < / text >

    < msgHeaders > ezE6RjAxTE9ZRE5MMjBCWFhYMDAzMjAw = < / msgHeaders >

    < msgTrailer > ezU6e0NISzpEOUFFRUNCN0NBQTl9e1RORzp9fQ == < / msgTrailer >

    < / object >

    < / data >

    Procedure: This works very well for a few xml record and fails for some.

    CREATE OR REPLACE PROCEDURE XML_EXTR
    AS
    CURSOR c1
    IS
    SELECT * FROM temp_XML;

    c1_cur c1% ROWTYPE;

    bamdata_sql VARCHAR2 (3000);
    d_text VARCHAR2 (3000);
    d_msgHeaders VARCHAR2 (3000);
    d_msgTrailer VARCHAR2 (3000);
    x_text VARCHAR2 (3000);
    x_msgHeaders VARCHAR2 (3000);
    x_msgTrailer VARCHAR2 (3000);
    x_eventType VARCHAR2 (3000);
    x_amount number (28.2).
    x_currency VARCHAR2 (3000);
    x_state VARCHAR2 (3000);
    x_units VARCHAR2 (3000);
    x_correspondentId VARCHAR2 (3000);
    X_TYPE VARCHAR2 (3000);
    x_receiverNetworks VARCHAR2 (3000);
    x_bankingPriority VARCHAR2 (3000);
    x_applicationCode VARCHAR2 (3000);
    x_processCounter VARCHAR2 (3000);
    x_obsolescence VARCHAR2 (3000);
    x_maxRetry VARCHAR2 (3000);
    x_retries VARCHAR2 (3000);
    x_fileSize VARCHAR2 (3000);
    x_endFct VARCHAR2 (3000);
    x_subType VARCHAR2 (3000);
    x_field20 VARCHAR2 (3000);
    x_sequenceNumber VARCHAR2 (3000);
    x_requestorDn VARCHAR2 (3000);
    x_responderDn VARCHAR2 (3000);
    x_SWIFTNetService VARCHAR2 (3000);
    x_transfertRef VARCHAR2 (3000);
    x_nonrepudiation VARCHAR2 (3000);
    x_transfertInfo VARCHAR2 (3000);
    x_fileDesc VARCHAR2 (3000);
    x_transfertDesc VARCHAR2 (3000);
    x_logicalName VARCHAR2 (3000);
    x_signIndicator VARCHAR2 (3000);
    x_critId VARCHAR2 (3000);
    x_inFapId VARCHAR2 (3000);
    x_deliveryNotif VARCHAR2 (3000);
    x_comment1 VARCHAR2 (3000);
    x_comment2 VARCHAR2 (3000);
    x_comment3 VARCHAR2 (3000);
    x_comment4 VARCHAR2 (3000);
    x_comments VARCHAR2 (3000);
    x_memo1 VARCHAR2 (3000);
    x_memo2 VARCHAR2 (3000);
    x_memo3 VARCHAR2 (3000);
    x_memo4 VARCHAR2 (3000);
    x_msgSecuLevel VARCHAR2 (3000);
    x_dates VARCHAR2 (3000);
    x_tuxedoPriority VARCHAR2 (3000);
    x_fileDest VARCHAR2 (3000);
    x_stkMsgPDEId VARCHAR2 (3000);
    x_EMTId VARCHAR2 (3000);
    x_LTRcptSyno VARCHAR2 (3000);
    x_LTRcpt VARCHAR2 (3000);
    x_LTEmis VARCHAR2 (3000);
    x_flow VARCHAR2 (3000);
    x_FINCopy VARCHAR2 (3000);
    x_msgDateVal VARCHAR2 (3000);
    x_eventDate VARCHAR2 (3000);
    x_typeReseauId VARCHAR2 (3000);
    x_inFapSeq1 VARCHAR2 (3000);
    x_inFapSeq2 VARCHAR2 (3000);
    x_direction VARCHAR2 (3000);
    x_priority VARCHAR2 (3000);
    x_ack VARCHAR2 (3000);
    x_format VARCHAR2 (3000);
    x_mur VARCHAR2 (3000);
    x_TexteType VARCHAR2 (3000);
    x_creatingUser VARCHAR2 (3000);
    x_fileinfo VARCHAR2 (3000);
    x_company VARCHAR2 (3000);
    x_language VARCHAR2 (3000);
    x_ackText VARCHAR2 (3000);
    x_jaxbRef VARCHAR2 (3000);
    x_jaxbElt VARCHAR2 (3000);
    x_memos VARCHAR2 (3000);
    xmlid number (28);
    x_msgRef1 VARCHAR2 (3000);
    x_msgRef2 VARCHAR2 (3000);
    x_msgRef3 VARCHAR2 (3000);
    x_msgRef4 VARCHAR2 (3000);
    x_sender VARCHAR2 (3000);
    x_amlBehavior VARCHAR2 (3000);
    x_ownerServiceId VARCHAR2 (3000);
    x_correspondentName VARCHAR2 (3000);
    x_correspondentAddress1 VARCHAR2 (3000);
    x_correspondentAddress2 VARCHAR2 (3000);
    x_correspondentAddress3 VARCHAR2 (3000);
    x_correspondentAddress4 VARCHAR2 (3000);
    x_correspondentCity VARCHAR2 (3000);
    x_correspondentCountry VARCHAR2 (3000);
    x_correspondentNetworkAddr VARCHAR2 (3000);
    x_tested VARCHAR2 (3000);
    x_correspondentNetwork VARCHAR2 (3000);
    x_validatedPercentage VARCHAR2 (3000);
    x_nbOfValid VARCHAR2 (3000);
    x_requestRef VARCHAR2 (3000);
    x_notifQueue VARCHAR2 (3000);
    x_requestType VARCHAR2 (3000);
    x_secBpid VARCHAR2 (3000);
    x_queue VARCHAR2 (3000);
    x_receiverCode VARCHAR2 (3000);
    x_receiverInd VARCHAR2 (3000);
    x_validFlag VARCHAR2 (3000);
    x_ownerId VARCHAR2 (3000);
    x_dn VARCHAR2 (3000);
    x_RMAOurBic VARCHAR2 (3000);
    x_RMACorrespondentBic VARCHAR2 (3000);
    x_RMAService VARCHAR2 (3000);
    x_fileMsgRef VARCHAR2 (3000);
    date of x_ext_date;
    x_correspondentAddress VARCHAR2 (3000);
    x_msgrefs varchar2 (3000);
    d_ackText varchar2 (3000);
    ackText varchar2 (3000);
    date of x_extdate;

    BEGIN

    FOR C1_CUR IN C1

    LOOP

    INSERT INTO data_GTT_TEMP)
    eventType, amount, currency, State, units, correspondentId, sender, receiverNetworks, bankingPriority, applicationCode, processCounter.
    obsolescence, maxRetry, reminders, fileSize, endFct, xsubType, field.20, sequenceNumber, requestorDn, responderDn, SWIFTNetService, non-repudiation,
    transfertRef, transfertInfo, fileDesc, transfertDesc, logicalName, signIndicator, critId, inFapId, deliveryNotif, comment1, comment2, comment3, comment4,
    Memo1, memo2, memo3, memo4, msgSecuLevel, dates, tuxedoPriority, fileDest, stkMsgPDEId, EMTId, LTRcptSyno, LTRcpt, LTEmis, flow, FINCopy, msgDateVal,
    eventDate, typeReseauId, inFapSeq1, inFapSeq2, direction, priority, ack,
    msgRef1, msgRef2, msgRef3, msgRef4, amlbehavior, correspondentName, ownerServiceId,
    correspondentAddress1, correspondentAddress2, correspondentAddress3, correspondentAddress4,
    correspondentCity, correspondentCountry, correspondentNetworkAddr, tested,
    correspondentNetwork, validatedPercentage, nbOfValid, requestRef, notifQueue,
    requestType, secBpid, xqueue, receiverCode, receiverInd, validFlag, ownerId, dn, RMAOurBic, RMACorrespondentBic, RMAService,
    fileMsgRef, format, xtype, wall, TexteType, creatingUser, fileinfo,
    company, text, xlanguage, ackText, msgHeaders, msgTrailer, jaxbRef, jaxbElt)
    SELECT
    x.eventType, x.amount, x.currency, x.state, x.units, x.correspondentId, x.sender, x.receiverNetworks, x.bankingPriority, x.applicationCode, x.processCounter,
    x.obsolescence, x.maxRetry, x.Retries, x.FileSize, x.endFct, x.xsubType, x.Field20, x.SequenceNumber, x.requestorDn, x.responderDn, x.SWIFTNetService, x.nonRepudiation,
    x.transfertRef, x.transfertInfo, x.fileDesc, x.transfertDesc, x.logicalName, x.signIndicator, x.critId, x.inFapId, x.deliveryNotif, x.comment1, x.comment2,
    x.comment3, x.comment4, x.Memo1, x.memo2, x.memo3, x.MEMO4, x.msgSecuLevel, x.dates, x.tuxedoPriority, x.fileDest, x.stkMsgPDEId, x.EMTId, x.LTRcptSyno,
    x.LTRcpt, x.LTEmis, x.flow, x.FINCopy, x.msgDateVal, x.eventDate, x.typeReseauId, x.inFapSeq1, x.inFapSeq2, x.direction, x.priority, x.ack,
    x.msgRef1, x.msgRef2, x.msgRef3, x.msgRef4, x.amlbehavior, x.correspondentName, x.ownerServiceId,
    x.correspondentAddress1, x.correspondentAddress2, x.correspondentAddress3, x.correspondentAddress4,
    x.correspondentCity, x.correspondentCountry, x.correspondentNetworkAddr, x.tested,
    x.correspondentNetwork, x.validatedPercentage, x.nbOfValid, x.requestRef, x.notifQueue,
    x.requestType, x.secBpid, x.xqueue, x.receiverCode, x.receiverInd, x.validFlag, x.ownerId, x.dn, x.RMAOurBic, x.RMACorrespondentBic, x.RMAService,
    x.fileMsgRef, x.format, x.xtype, x.mur, x.TexteType, x.creatingUser, x.fileinfo,
    x.Company, x.Text, x.xLanguage, x.ackText, x.msgHeaders, x.msgTrailer, x.jaxbRef, x.jaxbElt

    of temp_XML t, XMLTABLE (XMLNAMESPACES ('http://xmlextrac.test.com/object' as "ns0"), ' / ns0:event' )
    PASSAGE t.BAM_EVENT COLUMNS
    eventType varchar2 (3000) PATH 'data, object, eventType' DEFAULT NULL,
    amount number (28.2) path data/object/amounts"."
    currency varchar2 (3000) PATH 'data, object, currencys, currency' DEFAULT NULL,
    VARCHAR2 (3000) path "data/object / / state of ' DEFAULT NULL, State
    units varchar2 (3000) PATH ' object/data/units' DEFAULT NULL,
    correspondentId varchar2 (3000) PATH "data/object/correspondentIds' DEFAULT NULL,
    sender varchar2 (3000) PATH 'data, object, sender' DEFAULT NULL,
    receiverNetworks varchar2 (3000) PATH "data/object/receiverNetworks' DEFAULT NULL,
    bankingPriority varchar2 (3000) PATH "data/object/bankingPriority' DEFAULT NULL,
    applicationCode varchar2 (3000) PATH ' object/data/applicationCode' DEFAULT NULL,
    processCounter varchar2 (3000) PATH "data/object/processCounter' DEFAULT NULL,
    obsolescence varchar2 (3000) PATH ' data/object/obsolescence' DEFAULT NULL,
    maxRetry varchar2 (3000) PATH ' data/object/maxRetry' DEFAULT NULL,
    attempts to varchar2 (3000) "data/object/attempts" DEFAULT NULL path,.
    size of the file varchar2 (3000) PATH ' data/object/fileSize' DEFAULT NULL,
    endFct varchar2 (3000) PATH "data/object/endFct' DEFAULT NULL,
    xsubType varchar2 (3000) PATH "data/object/subtype' DEFAULT NULL,
    field.20 varchar2 (3000) PATH ' object/data/field.20' DEFAULT NULL,
    sequenceNumber varchar2 (3000) PATH "data/object/sequenceNumber" DEFAULT NULL,
    requestorDn varchar2 (3000) PATH "data/object/requestorDn' DEFAULT NULL,
    responderDn varchar2 (3000) PATH "data/object/responderDn' DEFAULT NULL,
    SWIFTNetService varchar2 (3000) PATH "data/object/SWIFTNetService' DEFAULT NULL,
    non-repudiation varchar2 (3000) PATH ' object/data/repudiation' DEFAULT NULL,
    transfertRef varchar2 (3000) PATH "data/object/transfertRef' DEFAULT NULL,
    transfertInfo varchar2 (3000) PATH "data/object/transfertInfo' DEFAULT NULL,
    fileDesc varchar2 (3000) PATH "data/object/fileDesc' DEFAULT NULL,
    transfertDesc varchar2 (3000) PATH "data/object/transfertDesc' DEFAULT NULL,
    logicalName varchar2 (3000) PATH "data/object/logicalName" DEFAULT NULL,
    signIndicator varchar2 (3000) PATH "data/object/signIndicator' DEFAULT NULL,
    critId varchar2 (3000) PATH "data/object/critId' DEFAULT NULL,
    inFapId varchar2 (3000) PATH "data/object/inFapId' DEFAULT NULL,
    deliveryNotif varchar2 (3000) PATH "data/object/deliveryNotif' DEFAULT NULL,
    COMMENT1 varchar2 (3000) PATH ' data, subject, comments, comment [1] "DEFAULT NULL,
    comment2 varchar2 (3000) PATH 'data, subject, comments, how [2]' DEFAULT NULL,
    comment3 varchar2 (3000) PATH "data/object/observations/comments [3]" DEFAULT NULL,
    comment4, varchar2 (3000) PATH ' data, subject, comments, comment [4] "DEFAULT NULL,
    Memo1 varchar2 (3000) PATH "data/object/memos/memo [1]" DEFAULT NULL,
    Memo2 varchar2 (3000) PATH "data/object/notes/Notes [2]" DEFAULT NULL,
    memo3 varchar2 (3000) PATH "data/object/memos/memo [3]" DEFAULT NULL,
    MEMO4 varchar2 (3000) PATH "data/object/memos/memo [4]" DEFAULT NULL,
    msgSecuLevel varchar2 (3000) PATH "data/object/msgSecuLevel' DEFAULT NULL,
    Date varchar2 (3000) PATH ' object/data/date' DEFAULT NULL,
    tuxedoPriority varchar2 (3000) PATH "data/object/tuxedoPriority' DEFAULT NULL,
    fileDest varchar2 (3000) PATH "data/object/fileDest' DEFAULT NULL,
    stkMsgPDEId varchar2 (3000) PATH "data/object/stkMsgPDEId' DEFAULT NULL,
    EMTId varchar2 (3000) PATH "data/object/EMTId' DEFAULT NULL,
    LTRcptSyno varchar2 (3000) PATH "data/object/LTRcptSyno' DEFAULT NULL,
    LTRcpt varchar2 (3000) PATH "data/object/LTRcpt' DEFAULT NULL,
    LTEmis varchar2 (3000) PATH "data/object/LTEmis' DEFAULT NULL,
    flow varchar2 (3000) PATH "/ object/data flow ' DEFAULT NULL,
    FINCopy varchar2 (3000) PATH ' data/object/FINCopy' DEFAULT NULL,
    msgDateVal varchar2 (3000) PATH "data/object/msgDateVal' DEFAULT NULL,
    eventDate varchar2 (3000) PATH "data/object/eventDate" DEFAULT NULL,
    typeReseauId varchar2 (3000) PATH "data/object/typeReseauId' DEFAULT NULL,
    inFapSeq1 varchar2 (3000) PATH "data/object/inFapSeq1' DEFAULT NULL,
    inFapSeq2 varchar2 (3000) PATH "data/object/inFapSeq2' DEFAULT NULL,
    direction varchar2 (3000) PATH 'data, object, direction' DEFAULT NULL,
    priority varchar2 (3000) PATH ' data/object/priority' DEFAULT NULL,
    ACK varchar2 (3000) PATH ' object/data/ack' DEFAULT NULL,
    msgRef1 varchar2 (3000) PATH ' data, object, msgRefs, msgRef [1] "DEFAULT NULL,
    msgRef2 varchar2 (3000) PATH ' data, object, msgRefs, msgRef [2] "DEFAULT NULL,
    msgRef3 varchar2 (3000) PATH ' data, object, msgRefs, msgRef [3] "DEFAULT NULL,
    msgRef4 varchar2 (3000) PATH ' data, object, msgRefs, msgRef [4] "DEFAULT NULL,
    amlBehavior varchar2 (3000) PATH "data/object/amlBehavior' DEFAULT NULL,
    ownerServiceId varchar2 (3000) PATH "data/object/ownerServiceId' DEFAULT NULL,
    correspondentName varchar2 (3000) PATH ' data/object/correspondentName' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of correspondentAddress1 ' object/data/correspondentLine1Addresse' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of correspondentAddress2 ' object/data/correspondentLine2Addresse' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of correspondentAddress3 ' object/data/correspondentLine3Addresse' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of correspondentAddress4 ' object/data/correspondentLine4Addresse' DEFAULT NULL,
    correspondentCity PATH VARCHAR2 (3000) ' object/data/correspondentCity' DEFAULT NULL,
    correspondentCountry PATH VARCHAR2 (3000) ' object/data/correspondentCountry' DEFAULT NULL,
    correspondentNetworkAddr PATH VARCHAR2 (3000) ' object/data/correspondentNetworkAddr' DEFAULT NULL,
    tested VARCHAR2 (3000) PATH ' data/object/tested' DEFAULT NULL,
    correspondentNetwork PATH VARCHAR2 (3000) ' object/data/correspondentNetwork' DEFAULT NULL,
    validatedPercentage PATH VARCHAR2 (3000) ' object/data/validatedPercentage' DEFAULT NULL,
    nbOfValid PATH VARCHAR2 (3000) ' object/data/nbOfValid' DEFAULT NULL,
    requestRef VARCHAR2 (3000) PATH ' data/object/requestRef' DEFAULT NULL,
    notifQueue PATH VARCHAR2 (3000) ' object/data/notifQueue' DEFAULT NULL,
    requestType PATH VARCHAR2 (3000) ' data/object/requestType' DEFAULT NULL,
    secBpid PATH VARCHAR2 (3000) ' object/data/secBpid' DEFAULT NULL,
    xqueue PATH VARCHAR2 (3000) ' data/object/tail' DEFAULT NULL,
    receiverCode PATH VARCHAR2 (3000) ' object/data/receiverCode' DEFAULT NULL,
    receiverInd PATH VARCHAR2 (3000) ' object/data/receiverInd' DEFAULT NULL,
    validFlag PATH VARCHAR2 (3000) ' object/data/validFlag' DEFAULT NULL,
    ownerId PATH VARCHAR2 (3000) ' data/object/ownerId' DEFAULT NULL,
    DN VARCHAR2 (3000) PATH ' data/object/dn' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of RMAOurBic ' object/data/RMAOurBic' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of RMACorrespondentBic ' object/data/RMACorrespondentBic' DEFAULT NULL,
    PATH of VARCHAR2 (3000) of RMAService ' object/data/RMAService' DEFAULT NULL,
    fileMsgRef PATH VARCHAR2 (3000) ' object/data/fileMsgRef' DEFAULT NULL,
    ackText varchar2 (3000) PATH "data/object/ackText' DEFAULT NULL,
    format varchar2 (3000) PATH "data/object / ' DEFAULT NULL,
    xType varchar2 (3000) PATH ' data/object/type' DEFAULT NULL,
    Wall varchar2 (3000) PATH ' data/object/wall' DEFAULT NULL,
    texteType varchar2 (3000) PATH "data/object/texteType' DEFAULT NULL,
    creatingUser varchar2 (3000) PATH ' data/object/creatingUser' DEFAULT NULL,
    fileInfo varchar2 (3000) PATH ' data/object/fileInfo' DEFAULT NULL,
    VARCHAR2 (3000) path ' data/object/society' DEFAULT NULL, the company
    VARCHAR2 (3000) text ' data/object/text' DEFAULT NULL path.
    xLanguage varchar2 (3000) PATH ' data/object/language' DEFAULT NULL,
    msgHeaders varchar2 (3000) PATH "data/object/msgHeaders' DEFAULT NULL,
    msgTrailer varchar2 (3000) PATH "data/object/msgTrailer' DEFAULT NULL,
    jaxbRef varchar2 (3000) PATH ' info/jaxbRef' DEFAULT NULL,
    jaxbElt varchar2 (3000) PATH "jaxbElt/info") x
    where t.XML_ID = c1_cur. XML_ID and t.status =' no;

    Select x.text, x.msgHeaders, x.msgTrailer in x_msgTrailer, x_msgHeaders, x_text of
    temp_XML t, XMLTABLE (XMLNAMESPACES ('http://xmlextrac.test.com/object' as "ns0"), ' / ns0:event' )
    PASSAGE t.BAM_EVENT COLUMNS
    text varchar2 (3000) PATH data/object/text"."
    msgHeaders varchar2 (3000) PATH "data/object/msgHeaders,"
    msgTrailer varchar2 (3000) PATH "object/data/msgTrailer.
    ) x
    where t.XML_ID = c1_cur. XML_ID;
    Select sysdate in double x_extdate;


    d_text: = utl_raw.cast_to_varchar2 (utl_encode.base64_decode (utl_raw.cast_to_RAW (x_text)));
    d_msgHeaders: = utl_raw.cast_to_varchar2 (utl_encode.base64_decode (utl_raw.cast_to_RAW (x_msgHeaders)));
    d_msgTrailer: = utl_raw.cast_to_varchar2 (utl_encode.base64_decode (utl_raw.cast_to_RAW (x_msgTrailer)));
    -d_ackText: = utl_raw.cast_to_varchar2 (utl_encode.base64_decode (utl_raw.cast_to_RAW (ackText)));

    Select
    EventType, amount, currency, State, units, correspondentid, sender, receivernetworks, bankingpriority,
    applicationcode, processcounter, obsolescence, maxretry, reminders, filesize, endfct, xsubtype, field.20, sequencenumber, requestordn,
    responderdn, swiftnetservice, non repudiation, transfertref, transfertinfo, filedesc, transfertdesc, logicalname, signindicator,
    critid, infapid, deliverynotif, comment1, comment2, comment3, comment4, memo1, memo2, memo3, memo4, msgseculevel, dates, tuxedopriority, filedest,
    stkmsgpdeid, emtid, ltrcptsyno, ltrcpt, ltemis, flow, fincopy, msgdateval, eventdate, typereseauid, infapseq1,
    infapseq2, direction, priority, ack, msgref1, msgref2, msgref3, msgref4, amlbehavior, ownerserviceid, correspondentname, correspondentaddress1, correspondentaddress2, correspondentaddress3, correspondentaddress4,
    correspondentcity, correspondentcountry, correspondentnetworkaddr, test, correspondentnetwork, validatedpercentage, nbofvalid,.
    requestref, notifqueue, requesttype, secbpid, xqueue, receivercode, receiverind, validflag, ownerid, dn, rmaourbic, rmacorrespondentbic, rmaservice, filemsgref,
    acktext, format, xtype, wall, textetype, creatinguser, fileinfo, society, text, xlanguage, msgheaders, msgtrailer, jaxbref, jaxbelt
    in
    x_eventtype, x_amount, x_currency, x_state, x_units, x_correspondentid, x_sender, x_receivernetworks, x_bankingpriority, x_applicationcode, x_processcounter,
    x_obsolescence, x_maxretry, x_retries, x_filesize, x_endfct, x_subtype, x_field20, x_sequencenumber, x_requestordn, x_responderdn, x_swiftnetservice, x_nonrepudiation,
    x_transfertref, x_transfertinfo, x_filedesc, x_transfertdesc, x_logicalname, x_signindicator, x_critid, x_infapid, x_deliverynotif, x_comment1, x_comment2, x_comment3,
    x_comment4, x_memo1, x_memo2, x_memo3, x_memo4, x_msgseculevel, x_dates, x_tuxedopriority, x_filedest, x_stkmsgpdeid, x_emtid, x_ltrcptsyno, x_ltrcpt,
    x_ltemis, x_flow, x_fincopy, x_msgdateval, x_eventdate, x_typereseauid, x_infapseq1, x_infapseq2, x_direction, x_priority, x_ack, x_msgref1, x_msgref2,
    x_msgref3, x_msgref4, x_amlbehavior, x_ownerserviceid, x_correspondentname, x_correspondentaddress1, x_correspondentaddress2, x_correspondentaddress3,
    x_correspondentaddress4, x_correspondentcity, x_correspondentcountry, x_correspondentnetworkaddr, x_tested, x_correspondentnetwork, x_validatedpercentage,
    x_nbofvalid, x_requestref, x_notifqueue, x_requesttype, x_secbpid, x_queue, x_receivercode, x_receiverind, x_validflag, x_ownerid, x_dn, x_rmaourbic,
    x_rmacorrespondentbic, x_rmaservice, x_filemsgref, x_acktext, x_format, x_type, x_mur, x_textetype, x_creatinguser, x_fileinfo, x_company, x_text,
    x_language, x_msgheaders, x_msgtrailer, x_jaxbref, data_GTT_TEMP x_jaxbelt;

    x_memos: = x_memo1 | » -'|| x_memo2 | » -'|| x_memo3 | » -'|| x_memo4;
    x_comments: = x_comment1 | » -'|| x_comment2 | » -'|| x_comment3 | » -'|| x_comment4;
    x_correspondentAddress: = x_correspondentAddress1 | » -'|| x_correspondentAddress2 | » -'|| x_correspondentAddress3 | » -'|| x_correspondentAddress4;
    x_msgrefs: = x_msgRef1 | » -'|| x_msgRef2 | » -'|| x_msgRef3 | » -'|| x_msgRef4;

    BEGIN


    insert into donnees_xml
    (xml_id, x_ext_date, eventtype, amount, currency, State, unit, correspondentid, sender, receivernetworks, bankingpriority, applicationcode,
    ProcessCounter, obsolescence, maxretry, reminders, filesize, endfct, xsubtype, field.20, sequencenumber, requestordn, responderdn,
    swiftnetservice, non repudiation, transfertref, transfertinfo, filedesc, transfertdesc, logicalname, signindicator, critid, infapid,
    deliverynotif, comments, notes, msgseculevel, dates, tuxedopriority, filedest, stkmsgpdeid, emtid, ltrcptsyno, ltrcpt, ltemis, flow,
    FINCopy, msgdateval, eventdate, typereseauid, infapseq1, infapseq2, direction, priority, ack, msgrefs, amlbehavior, ownerserviceid,
    correspondentName correspondentaddress, correspondentcity, correspondentcountry, correspondentnetworkaddr, tested,
    correspondentnetwork, validatedpercentage, nbofvalid, requestref, notifqueue, requesttype, secbpid, xqueue, receivercode,
    receiverind, validflag, ownerid, dn, rmaourbic, rmacorrespondentbic, rmaservice, filemsgref, acktext, format, xtype, wall,
    textetype, creatinguser, fileinfo, society, text, xlanguage, msgheaders, msgtrailer, jaxbref, jaxbelt)
    values
    (xmlid, x_extdate, x_eventType, x_amount, x_currency, x_state, x_units, x_correspondentId, x_sender, x_receiverNetworks, x_bankingPriority, x_applicationCode,
    x_processCounter, x_obsolescence, x_maxRetry, x_retries, x_fileSize, x_endFct, x_subType, x_field20, x_sequenceNumber, x_requestorDn, x_responderDn,
    x_SWIFTNetService, x_nonRepudiation, x_transfertRef, x_transfertInfo, x_fileDesc, x_transfertDesc, x_logicalName, x_signIndicator, x_critId, x_inFapId,
    x_deliveryNotif, x_comments, x_memos, x_msgSecuLevel, x_dates, x_tuxedoPriority, x_fileDest, x_stkMsgPDEId, x_EMTId, x_LTRcptSyno, x_LTRcpt, x_LTEmis, x_flow,
    x_FINCopy, x_msgDateVal, x_eventDate, x_typeReseauId, x_inFapSeq1, x_inFapSeq2, x_direction, x_priority, x_ack, x_msgrefs, x_amlbehavior, x_ownerServiceId,
    x_correspondentName, x_correspondentAddress, x_correspondentCity, x_correspondentCountry, x_correspondentnetworkaddr, x_tested,
    x_correspondentNetwork, x_validatedPercentage, x_nbOfValid, x_requestRef, x_notifQueue, x_requestType, x_secBpid, x_queue, x_receiverCode,
    x_receiverInd, x_validFlag, x_ownerId, x_dn, x_RMAOurBic, x_RMACorrespondentBic, x_RMAService, x_fileMsgRef, ackText, x_format, x_type, x_mur,
    x_TexteType, x_creatingUser, x_fileinfo, x_company d_text, x_language, d_msgHeaders, d_msgTrailer, x_jaxbRef, x_jaxbElt);

    Update temp_XML set status = 'Y' where XML_ID = xmlid;

    END;
    COMMIT;
    END LOOP;
    END;
    /

    1.No. multiple tag will vary how to extract those and concatenate them into a single column. I assumed that his occrrence in 3 for example:

    Use the fn:string-join() function:

    path varchar2 (4000) of comments 'string-join(comments/comment, "-").

    2. how to set the value NULL if no tag is not present. Tag in XML record number can vary.

    You don't have anything specific to do in this case.

    Missing tags with a projection in the COLUMNS clause will produce a column NULL by default.

  • How to extract the XML with namespace?

    Hi all

    Here's the XML I:

    <? XML version = "1.0" encoding = "UTF-8"? >
    -< transaction xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://schemas.test.com/Support/Services/test1/2012" xsi: schemaLocation = "http://schemas.test.com/Support/Services/test1/2012 Support.test1.v1.xsd" >
    -< application >
    < > 10 Sam < / Sam >
    < > 32 Actid < / Actid >
    < Pax > 3 < / Pax >
    < > 10 - DEC - 2012 Flt < / Flt >
    < user name > WebUserNameTest < / name >
    < / request >
    < application >
    < Sam > 1 < / Sam >
    < Actid > 3 < / Actid >
    < > 2 Pax < / Pax >
    < Flt > 2012 - dec - 12 < / Flt >
    < user name > WebUserNameTest < / name >
    < / request >
    < / transaction >

    I need to extract the item values:

    The code below will help me when I have no namespace, what needs to be done in order to work with the value of the element namespace and etract

    v_string_xml: =.
    ' / / Query [' |] To_char (counter_xml) | '] / Sam / text () ';
    v_ssp_table (v_ssp_table. COUNTY) .memid: =.
    p_xml_in. EXTRACT (v_string_xml) .getnumberval ();


    v_string_xml: =.
    ' / / Query [' |] To_char (counter_xml) | '] / Actid / text () ';
    v_ssp_table (v_ssp_table. COUNTY) .actid: =.
    p_xml_in. EXTRACT (v_string_xml) .getnumberval ();

    v_string_xml: =.
    ' / / Query [']
    || To_char (counter_xml)
    || '] / Pax / text () ';
    v_ssp_table (v_ssp_table..) Pax COUNT): =.
    p_xml_in. EXTRACT (v_string_xml) .getnumberval ();

    v_string_xml: =.
    ' / / Query [' |] To_char (counter_xml) | '] / Flt / text () ';
    v_ssp_table (v_ssp_table..) Flt COUNT): =.
    p_xml_in. EXTRACT (v_string_xml) .getstringval ();

    v_string_xml: =.
    ' / / Query [']
    || To_char (counter_xml)
    || '] / Username / text () ';
    v_ssp_table (v_ssp_table. COUNTY) .username: =.
    p_xml_in. EXTRACT (v_string_xml) .getstringval ();
    declare
      v_xml xmltype := xmltype( '
    
    
    10
    32
    3
    2012-DEC-10
    WebUserNameTest
    
    
    1
    3
    2
    2012-DEC-12
    WebUserNameTest
    
    ' );
    begin
      for r_xml in ( select *
                     from xmltable( xmlnamespaces( default 'http://schemas.test.com/Support/Services/test1/2012' )
                                   , '/Transaction/Request'
                                   passing v_xml
                                     columns memid number path 'Memid'
                                           , actid number path 'Actid'
                                           , pax number path 'Pax'
                                           , flt varchar2(100) path 'Flt'
                                           , username varchar2(100) path 'Username'
                                  )
                   )
      loop
        dbms_output.put_line( r_xml.memid );
        dbms_output.put_line( r_xml.actid );
        dbms_output.put_line( r_xml.pax );
        dbms_output.put_line( r_xml.flt );
        dbms_output.put_line( r_xml.username );
      end loop;
    end;
    
  • Questions to extract the XMLtype column attributes

    I cannot retrieve the values of a column of the XML data type. There are 16 fields and when I try to extract the data the XML snippet is that each of them in 1 great return value. I have tried everything but the problem seems to be that the domain name is an attribute and everything I try fails. I appreciate any help in advance and I'm extremely new XML so please let me know if you need more information.

    With the help of Oracle 11.2.0.2 Express

    -Created table that has a column of XMLTYPE OF CLOB
    CREATE THE TABLE HR. XMLTABLESTORE (key_id VARCHAR2 (10) PRIMARY KEY, xmlloaddate date, xml_column XMLTYPE) AS CLOB XmlType xml_column STORE;

    -Insert the XML code in the column
    INSERT INTO HUMAN RESOURCES. VALUES XMLTABLESTORE (HR. XMLSEQUENCE. NEXTVAL, SYSDATE, XMLType (bfilename ('XMLDIRX', 'PROD_20110725_211550427_220b.xml'),
    nls_charset_id ('AL32UTF8')));

    I managed to get the values for

    SELECT extract (xml_column, ' / / MapItem/@ProductNum "") ProductNum go OF HR. XMLTABLESTORE

    '63481062975'

    Vain, get the data under the domain name, as it is to return all names or values

    SELECT extract (xml_column, ' / / MapItem/Field/@Name "") OF HR. XMLTABLESTORE

    'lowDispUnitsPerPackdosageFormmedicaidUnitTypemedicareUnitTypemedicareUnitsPerPackunitConversiontypeunitMeasurepricingUnitMeasurelabelerCodeproductNumdescriptionlongDescriptiondesiIndicatorgenericBrandTypeendoOrgCode'

    How can I return a row of data both for the name and value?

    <? XML version = "1.0"? > < entries >
    < ProductNum category = NDC "634810629" = "634810629" Name = "634810629" Ndc9Flag = "true" >
    < = field name "type" Type = "java.lang.String" Value = "Category" / > "
    < name of field = "productNum" Type = "java.lang.String" Value = "634810629" / > "
    "" "< MapItem ProductNum = NDC"63481062975"="63481062975"Ndc9Flag ="false"name ="PERCOCET 10/325 MG x 100 UD' status = "0" Description ="PERCOCET 10/325 MG x 100 UD ' MedicaidUnitsPerPack ="100.0"MarketEntryDate ="2001-11-23 00:00:00 "FirstSalesDate =" 2001-11-23 00:00:00 "fdaApprovalDate ="2001-11-23"fdaRegName ="000000006348162975"ManuTermDate ="2003-09-30 00:00:00 "ShelfLifeExpDate =" 2003-09-30 00:00:00 "drugType ="Rx"DrugCategory =" N"TheraCode ="NR"EligibleForVA ="false"EligibleForPHS ="false"EligibleForASP ="false"EligibleForMedicaid ="true"NonCmtyPharmaDrug ="false">"
    * < name of field = "lowDispUnitsPerPack" Type = "java.lang.String" Value = "1000" / > * "
    * < name of field = 'dosageForm"Type =" java.lang.String"Value = 'TAB' / > *"
    * < name of field = "medicaidUnitType" Type = "java.lang.String" Value = 'TAB' / > * "
    * < name of field = "medicareUnitType" Type = "java.lang.String" Value = 'TAB' / > * "
    * < name of field = "medicareUnitsPerPack" Type = "java.lang.String" Value = "100.0" / > * "
    * < name of field = "unitConversion" Type = "java.lang.String" Value = "1" / > * "
    * < = field name "type" Type = "java.lang.String" Value = "Item" / > * "
    * < name of field = 'unitMeasure' Type = "java.lang.String" Value = "EA" / > * "
    * < name of field = "pricingUnitMeasure" Type = "java.lang.String" Value = "EA" / > * "
    * < name of field = "labelerCode" Type = "java.lang.String" Value = "63481" / > * "
    * < name of field = "productNum" Type = "java.lang.String" Value = "63481062975" / > * "
    * < field name = "description" Type = "java.lang.String" Value ="PERCOCET 10/325 MG x 100 UD" / > * "
    * < field name = "longDescription" Type = "java.lang.String" Value ="PERCOCET 10/325 MG x 100 UD" / > * "
    * < name of field = "desiIndicator" Type = "com.modeln.bp.catalog.CMnDesiDrugIndicator" Value = "2" / > * "
    * < name of field = "genericBrandType" Type = "com.modeln.bp.struct.contract.enums.CMnGenericBrandItemType" Value = "BRND" / > * "
    * < name of field = "endoOrgCode" Type = "java.lang.String" Value = "0010" / > * "
    < / MapItem >
    < / category >
    < / input >

    Thank you
    Shawn

    You can get a picture with lines like ['name', 'value']

    with t as
    (select xmltype('
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ') xml from dual)
    
    select  x.name, x.value
    from t
        ,xmltable('/Entries/Category/MapItem/Field'
                  passing t.xml
                  columns name varchar2(20) path '@Name',
                   value varchar2(20) path '@Value'
                 ) x 
    
    NAME                 VALUE
    -------------------- --------------------
    lowDispUnitsPerPack  1.000
    dosageForm           TAB
    medicaidUnitType     TAB
    medicareUnitType     TAB
    medicareUnitsPerPack 100.0
    unitConversion       1
    type                 Item
    unitMeasure          EA
    pricingUnitMeasure   EA
    labelerCode          63481
    productNum           63481062975
    description          PERCOCET 10/325MG x
    longDescription      PERCOCET 10/325MG x
    desiIndicator        2
    genericBrandType     BRND
    endoOrgCode          0010                 
    
    16 rows selected           
    
  • Extract the XML element in Oracle

    Hi all

    I am trying to extract a value from the XML. But I'm not able to do.

    I gave below the XML and the request which I use to recover data.

    Please help me in this regard.

    query:
    --------

    SELECT A.ixml.EXTRACT ('/ / ns1:clm / ns1:provBill [@T = "85"] [@T = "EI"] /id / text () "," xmlns:ns1 = "http://xyz.com/ac/xsd/LoanV2.0.3" "") .getstringval
    value_str)
    LOAN one
    WHERE a.Loan_reference_id = 286;


    SELECT A.ixml.EXTRACT ('/ ns0:LoanWrapperRequest / ns0:LoanRequest/CXmlPayload/ns1:clm / provBill [@T = "85"] [@T = "EI"] /id / text () "," xmlns:ns0 = "http://xyz.com/ac/activator/schema/LoanWrapper" xmlns:ns1 = "http://xyz.com/ac/xsd/LoanV2.0.3" "") .getstringval
    value_str)
    LOAN one
    WHERE a.Loan_reference_id = 286;

    XML:
    -----
    < ns0:LoanWrapperRequest xmlns:ns0 = "http://xyz.com/ac/activator/schema/LoanWrapper" >
    < ns0:LoanRequest xmlns:msgns = "http://xyz.com/wsdl/ActivatorBpel/TrigActivatorQue" xmlns:ns1 = "http://xyz.com/wsdl/PersistLoanLogs/persistLoanLog" >
    < RequestHeader mlns = "http://xyz.com/ac/activator/schema/LoanWrapper" >
    < SourceSystem > OKC < / SourceSystem >
    < ServiceWorkflow >
    < ServiceInfo >
    < ServiceName > ACActivator < / ServiceName >
    < / ServiceInfo >
    < / ServiceWorkflow >
    < / RequestHeader >
    < cXmlPayload xmlns = "http://xyz.com/ac/activator/schema/LoanWrapper" >
    < ns1:clm xmlns:ns1 = "http://xyz.com/ac/xsd/LoanV2.0.3" >
    < hdr xmlns = "http://xyz.com/ac/xsd/LoanV2.0.3" >
    eTest1126saggy < corn > < / corn >
    < idSend > 123456789 < / idSend >
    < nmSend T '41' = > ABC SUBMITTER < / nmSend >
    < contact >
    < n > JOHN SMITH < /nm >
    < T comm = "TE" > 5555551234 < / comm >
    < / contact >
    < dtSend > 090831 < / dtSend >
    < tmSend > 1440 < / tmSend >
    < indAck > 1 < / indAck >
    < indTest > P < / indTest >
    < worm > 00501 < / worm >
    < numIsa > 999999999 < / numIsa >
    < numGs > 1 < / numGs >
    < > 0001 numTs < / numTs >
    <!-< IdBht > 20090831 < / IdBht >->
    < cdClmType > CH < / cdClmType >
    < / hdr >
    < provBill T = "85" xmlns = "http://xyz.com/ac/xsd/LoanV2.0.3" >
    < cdTaxon T 'BI' = > 207Q00000X < / cdTaxon >
    < name >
    ABC Group Practice < nmOrg > < / nmOrg >
    < / name >
    < id P = "P" T = "XX" > 145 / < ID > "
    < id T = 'EI' > 234 / < ID >
    < id T = "24" > 234 / < ID >
    < addr >
    LN of billing address 123 < addr1 > < / addr1 >
    < City > Nashville < / City >
    < cdState > TN < / cdState >
    < cdPostal > 37214 < / cdPostal >
    < / addr >
    < contact >
    < n > JOHN SMITH < /nm >
    < T comm = "TE" > 5555551234 < / comm >
    < comm T = 'EX' > 123 < / comm >
    < / contact >
    < cdCurr T '85' = > CAD < / cdCurr >
    < / provBill >
    < / ns1:clm > < / CXmlPayload > < / ns0:LoanRequest > < / ns0:LoanWrapperRequest >



    best regards
    Swami

    Once again, with the full qualified path, which is preferable from the point of view of optimization, careful inspection of the nodes parents led to the conclusoon they are also in the same namespace, so the following works

     62  select VALUE_STR
     63    from LOAN A,
     64         XMLTABLE
     65         (
     66           xmlnamespaces
     67           (
     68             'http://xyz.com/ac/activator/schema/LoanWrapper' as "ns0",
     69             'http://xyz.com/ac/xsd/LoanV2.0.3' as "ns1"
     70           ),
     71           '/ns0:LoanWrapperRequest/ns0:LoanRequest/ns0:CXmlPayload/ns1:clm/ns1:provBill[@T="85"]'
     72           passing IXML
     73           columns
     74           VALUE_STR varchar2(32) path 'ns1:id[@T="EI"]/text()'
     75         )
     76  /
    
    VALUE_STR
    --------------------------------
    234
    
    SQL>
    
  • Difficult to extract multiple values from an XML document

    I have the following XML Document
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <ActivityId CorrelationId="4fc67c0d-4416-4c1f-92c5-0d6624fb41fd" 
    xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">30ccb32d-d6f5-4442-a41a-1eb735112501</ActivityId>
       </s:Header>
       <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <FacilitySiteInteractionList xmlns="urn:WA.Ecy.ADS.FacilitySite.Services">
             <FacilitySiteInteraction>
                <Id>78105</Id>
                <StartDate>2009-07-31T00:00:00</StartDate>
                <StatusCode>65</StatusCode>
                <InteractionTypeCode>WQGSWI</InteractionTypeCode>
                <FacilitySiteId>14951</FacilitySiteId>
                <CurrentSystemProgramName>WATQUAL</CurrentSystemProgramName>
                <CurrentSystemName>WPLCS</CurrentSystemName>
                <FederalProgramId/>
                <EndDate xsi:nil="true"/>
                <InteractionId>78105</InteractionId>
                <ProgramFacilitySiteName>Hedwall Inc.</ProgramFacilitySiteName>
                <ModifiedDate>2009-07-31T07:30:57.99</ModifiedDate>
                <ModifiedByName>taus461</ModifiedByName>
                <CreatedDate>2009-07-31T07:30:57.99</CreatedDate>
                <FS_FEATUREs/>
             </FacilitySiteInteraction>
             <FacilitySiteInteraction>
                <Id>78104</Id>
                <StartDate>2009-07-01T00:00:00</StartDate>
                <StatusCode>65</StatusCode>
                <InteractionTypeCode>WQMJIND</InteractionTypeCode>
                <FacilitySiteId>14951</FacilitySiteId>
                <CurrentSystemProgramName>WATQUAL</CurrentSystemProgramName>
                <CurrentSystemName>WPLCS</CurrentSystemName>
                <FederalProgramId/>
                <EndDate xsi:nil="true"/>
                <InteractionId>78104</InteractionId>
                <ProgramFacilitySiteName>Hedwall Inc.</ProgramFacilitySiteName>
                <ModifiedDate>2009-07-31T07:24:02.76</ModifiedDate>
                <ModifiedByName>taus461</ModifiedByName>
                <CreatedDate>2009-07-31T07:24:02.76</CreatedDate>
                <FS_FEATUREs/>
             </FacilitySiteInteraction>
          </FacilitySiteInteractionList>
          <TotalRowCount xmlns="urn:WA.Ecy.ADS.FacilitySite.Services">2</TotalRowCount>
       </s:Body>
    </s:Envelope>
    I need to retrieve the Id of the node FacilitySiteInteraction - in this case, the values are 78104 and 78105.

    I tried to use extractvalue just, but he hesitates with error ORA-19025.
    select extractvalue(x,'//FacilitySiteInteractionList/FacilitySiteInteraction/Id','xmlns="urn:WA.Ecy.ADS.FacilitySite.Services"')
    from my_tab;
    
    ERROR at line 2:
    ORA-19025: EXTRACTVALUE returns value of only one node
    
    -- note: column my_tab.x is an xmltype data type
    If I use just extracted I see there the rub
    select extract(x,'//FacilitySiteInteractionList/FacilitySiteInteraction/Id',
    'xmlns="urn:WA.Ecy.ADS.FacilitySite.Services"')
    from my_tab;
    
    <Id xmlns="urn:WA.Ecy.ADS.FacilitySite.Services">78105</Id><Id xmlns="urn:WA.Ecy.ADS.FacilitySite.Services">78104</Id>
    The format of the XML document does not have to consider another records/lines.

    So, the next thing I tried was using the value of the iterator:
    select extractvalue(x,'//FacilitySiteInteractionList/FacilitySiteInteraction[2]/Id',
    'xmlns="urn:WA.Ecy.ADS.FacilitySite.Services"')
    from my_tab;
    
    78104
    The downside of what I see is that I must first enter the TotalRowCount value and then more wrap XML Document TotalRowCount times
    in order to get these values. So I was wondering if it is a more effective approach to enter these data?

    Thank you, Tony
    SQL>  with t as (
    select xmltype('
    
       
          30ccb32d-d6f5-4442-a41a-1eb735112501
       
       
          
             
                78105
                2009-07-31T00:00:00
                65
                WQGSWI
                14951
                WATQUAL
                WPLCS
                
                
                78105
                Hedwall Inc.
                2009-07-31T07:30:57.99
                taus461
                2009-07-31T07:30:57.99
                
             
             
                78104
                2009-07-01T00:00:00
                65
                WQMJIND
                14951
                WATQUAL
                WPLCS
                
                
                78104
                Hedwall Inc.
                2009-07-31T07:24:02.76
                taus461
                2009-07-31T07:24:02.76
                
             
          
          2
       
    ') xml from dual
    )
    --
    select x.* from t t, xmltable('declare namespace e="urn:WA.Ecy.ADS.FacilitySite.Services";
                                 //e:Id' passing t.xml.extract('//FacilitySiteInteraction','xmlns="urn:WA.Ecy.ADS.FacilitySite.Services"')
                                 columns Id int path '.') x
    /
            ID
    ----------
         78105
         78104
    
    2 rows selected.
    
  • Extract the duplicated columns

    Hello Experts,


    SELECT * FROM v$ VERSION;

    Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
    PL/SQL Release 8.1.7.4.0 - Production
    CORE 8.1.7.0.0-Production
    AMT for IBM/AIX RISC System/6000: Version 8.1.7.4.0 - Production
    NLSRTL Version 3.4.1.0.0 - Production


    I am trying to retrieve all the values of column twice in the table.

    For example;
    SELECT     DISTINCT cross_reference_type FROM test_mtl_cross_references;
    
    CROSS_REFERENCE_TYPE
    =====================
    ATG_Code
    UPC
    SCC20
    Shelf
    World-wide
    
    
    
    CREATE TABLE test_mtl_cross_references(INVENTORY_ITEM_ID NUMBER,CROSS_REFERENCE_TYPE VARCHAR2 (25));
    
    INVENTORY_ITEM_ID    CROSS_REFERENCE_TYPE
    
    830450    ATG_Code
    830450    ATG_Code
    830450    UPC
    830450    Shelf
    830452    World-wide
    830454    World-wide
    I need to extract only the records that is repeated twice for the same "CROSS_REFERENCE_TYPE."

    Desired output
    INVENTORY_ITEM_ID    CROSS_REFERENCE_TYPE
    830450    ATG_Code
    I'm trying with ROW_NUMBER. But, if I use a CASE statement, then if the user wants to add one more additional cross_reference_type, then my request will not give appropriate :(results

    Help, please... Thank you...

    SELECT     inventory_item_id, cross_reference_type
                ,ROW_NUMBER ()
                        OVER (
                             PARTITION BY inventory_item_id
                             ORDER BY CASE format
                                                 WHEN 'ATG_Code' THEN 1
                                                 WHEN 'UPC' THEN 2
                                                 WHEN 'SCC20' THEN 3
                                                 WHEN 'Shelf' THEN 4
                                                 WHEN 'World-wide' THEN 5
                                            END
                        )
                        AS RANK
    FROM          test_mtl_cross_references

    Select INVENTORY_ITEM_ID, CROSS_REFERENCE_TYPE
    of test_mtl_cross_references
    INVENTORY_ITEM_ID group, CROSS_REFERENCE_TYPE
    having count (*) = 2
    /

    ---------------

    Sybrand Bakker
    Senior Oracle DBA

  • Req SQL syntax. to extract the value XML [CLOB]

    Hello

    I'll have the XML column in my table.

    I have XML value in CLOB data type. I had an experience using extract XML from SQL syntax.

    But I am unable to extract this file. I need to meet tagname value XML who gave example below.

    For example, the name of the Table is A
    Column name is A1

    The value of column given below here.

    <? XML version = "1.0" encoding = "ISO-8859-1? > < tags > < tag > < tagname > {docval} < / tagname > < tagvalue > ESPRefNotice < / tagvalue > < / tag > < tag > < tagname > {: inputvalue} < / tagname > < tagvalue > 3216 < / tagvalue > < / tag > < tag > < tagname > {officename} < / tagname > < tagvalue > ssvofficename < / tagvalue > < / tag > < / tags >

    Kindly help me on this to extract the value 'tagname' or 'tagvalue' according to the above xml data.

    Thank you
    SELECT warehouse_name warehouse,
       warehouse2."Water", warehouse2."Rail"
       FROM warehouses,
       XMLTABLE('/Warehouse'
          PASSING warehouses.warehouse_spec
          COLUMNS
             "Water" varchar2(6) PATH '/Warehouse/WaterAccess',
             "Rail" varchar2(6) PATH '/Warehouse/RailAccess')
          warehouse2;
    

    check this exp in the documentation
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions228.htm#CIHGGHFB

    the warehouse_spec is of type xmltype. So in your case it is clob then you need to add like what I did in the query...
    XmlType ()...

    Hope that explains everything...

    Ravi Kumar

  • How to extract the values of column aliases based on different column values?

    Hello gurus,

    I have a table with the following struture-
    "drop table T;
    create table T(Name, Symbol, Amount,dep) as select
    'Anderia', 'AA', 1050000,'HR' from dual union all select
    'Michael', 'ML',150000,'Sales' from DUAL union all select
    'Bill', 'BL', 1050000,'Finance' from dual union all select
    'Nancy', 'NY', 4000,'HR' from DUAL union all select
    'Anderia', 'AA',3000,'HR' from dual union all select
    'Michael', 'ML',1050000,'Sales' from DUAL union all select
    'Bill', 'BL', 1200000,'Finance' from DUAL union all select
    'Anderia', 'AA', 1200000,'HR' from DUAL union all select
    'Vish', 'VH', 1200000,'Marketing' from DUAL;"
    And try to find the values of the column as
    Name, symbol, dep, amount, % Total, Total $Cumm, rank but some additional as-columns

    Amount HR, % HRTotal, $HR Cumm Total,
    Finance amount, FinanceTotal %, $Finance Cumm Total
    Sales amount, a percentage of Total sales, $Sales Cumm Total.
    Amount marketing, MarketingTotal %, $Marketing Cumm Total

    then I use the following query to retrieve the name, the symbol, the dep, amount, % Total, Total $Cumm, rank columns.
    select name
         , decode(grouping(symbol), 0, symbol, 'Total') symbol
         , dep
         , sum(amount) amount
         , sum(per_total) "% Total"
         , decode(grouping(symbol), 0, max(Cum_per_total), null) "% Cumm Total"
         , decode(grouping(symbol), 0, max(rank), null) rank
      from (
              select name
                   , symbol
                , dep
                   , amount
                   , per_total 
                   , sum(per_total) over(order by rk) cum_per_total
                   , rank
                   , rk
                from (     
                        select name
                             , symbol
                    , dep
                             , sum(amount) amount
                             , round((sum(amount)/max(total_amount)) * 100,2) per_total
                             , dense_rank () over (order by sum(amount) desc) as rank
                             , row_number() over(order by sum(amount) desc) as rk
                          from (
                                 select name
                                      , symbol
                                      , amount
                          , dep
                                      , sum(amount) over() total_amount 
                                      , sum(amount) over () 
                                   from t
                               )
                         group 
                            by name, symbol, dep
                    )
            )
      group         
         by grouping sets((name, symbol, dep), ())
      order by rank, max(rk) nulls last
    But I want to extract the following columns so... How can I do?

    Amount HR, % HRTotal, $HR Cumm Total,
    Finance amount, FinanceTotal %, $Finance Cumm Total
    Sales amount, a percentage of Total sales, $Sales Cumm Total.
    Amount marketing, MarketingTotal %, $Marketing Cumm Total


    as I want that all records, then will the dep..do-specific I need to use the case here?
    Thanks for all your time and effort in advance

    If I understand your needs, you need pivot: SQL and PL/SQL FAQ

  • Need help to retrieve the value of an xml tag.

    Hi all

    Hello all, I have problem to extract a value from an xml tag. I created an xml schema based on the schema, I created an xmltype table and inserted a value to the table. When I try to extract a value of a particular tag I can't do... Kindly help me to solve this problem. Here by I write all working, I did...

    I use the following client:
    -----------------------------------

    SQL * more: Release 10.2.0.1.0 - Production on Mon 31 Jan 11:44: 59 2011

    Copyright (c) 1982, 2005, Oracle. All rights reserved.


    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With partitioning, OLAP and Data Mining options


    ////////////////////////////////// XML Schema ///////////////////////

    Start
    () dbms_xmlschema.registerSchema
    "http://www.oradev.com/chipsxml.xsd,"
    ' < scheme xmlns = "http://www.w3.org/2001/XMLSchema".
    targetNamespace = "http://www.oradev.com/chipsxml.xsd."
    xmlns:SAMP = "http://www.oradev.com/chipsxml.xsd".
    version = "1.0" >

    < feature name = 'Field1' >
    < complexType >
    <>sequence
    < element name = "UTI" >
    < complexType >
    <>sequence
    < element name = "U01" type = "string" / >
    < element name = "U02" type = "string" / >
    < element name = "U03" type = "string" / >
    < element name = "U03a" type = "string" / >
    < element name = "U03b" type = "string" / >
    < element name = "U03c" type = "string" / >
    < element name = "U04" type = "string" / >
    < element name = "U05" type = "string" / >
    < / sequence >
    < / complexType >
    < / item >
    < / sequence >
    < / complexType >
    < / item >
    < / schema > ',
    (TRUE, TRUE, FALSE, FALSE);
    end;


    A table that has several column.

    CREATE TABLE chipsxmltable1)
    Identification number, XMLDATA XmlType)
    XMLTYPE XMLDATA STORE AS OBJECT / RELATIONAL
    XMLSCHEMA 'http://www.oradev.com/chipsxml.xsd '.
    ELEMENT 'field1 ';


    Insert the query in chipsxmltable.

    INSERT INTO (VALUES) chipsxmltable
    XmlType.CreateXml ("<?") XML version = "1.0"? >
    < xmlns:samp samp: field1 = "http://www.oradev.com/chipsxml.xsd" >
    < USE >
    No. < U01 > < / U01 >
    Y < U02 > < / U02 >
    Y < U03 > < / U03 >
    < U03a > Y < / U03a >
    < U03b > Y < / U03b >
    < U03c > Y < / U03c >
    Y < U04 > < / U04 >
    Y < U05 > < / U05 >
    < / UTI >
    ((< / samp: field1 > '));


    To display the data in a field with the structure:
    --------------------------------------------

    1. motion:
    ----------
    Select * from chipsxmltable1;

    Output:
    -------


    ID XMLDATA
    ---------- -----------------------------------------------------------------
    1 <? XML version = "1.0"? >
    < xmlns:samp samp: field1 = "http://www.oradev.com/chipsxml.xsd" >
    < USE >
    No. < U01 > < / U01 >
    No. < U02 > < / U02 >
    Y < U03 > < / U03 >
    < U03a > Y < / U03a >
    < U03b > Y < / U03b >
    < U03c > Y < / U03c >
    Y < U04 > < / U04 >
    Y < U05 > < / U05 >
    < / UTI >
    < / samp: field1 >


    2 query: (both the query shows the same result)
    ----------

    SELECT X.xmldata.getClobVal ('XMLDATA' FROM chipsxmltable1 X);

    Select extract (XMLDATA, "/ Field1'") .getstringval ("XMLDATA" chipsxmltable1 x);


    Output:
    --------

    XMLDATA
    -----------------------------------------------------------------
    <? XML version = "1.0"? >
    < xmlns:samp samp: field1 = "http://www.oradev.com/chipsxml.xsd" >
    < USE >
    No. < U01 > < / U01 >
    No. < U02 > < / U02 >
    Y < U03 > < / U03 >
    < U03a > Y < / U03a >
    < U03b > Y < / U03b >
    < U03c > Y < / U03c >
    Y < U04 > < / U04 >
    Y < U05 > < / U05 >
    < / UTI >
    < / samp: field1 >


    To display the data as a single string without structure using "getstringval()":
    ---------------------------------------------------------------------------------

    3 query
    ---------

    Select extract (XMLDATA, "//text()').getstringval()"CHIPS - XML"of chipsxmltable1 x;)

    Output:
    -------

    CHIPS - XML
    ---------------------
    NoNoYYYYYY


    To display the data as a single string without structure using "getclobval()":
    ---------------------------------------------------------------------------------

    4 query
    -------

    Select extract (XMLDATA, "//text()').getClobVal()"CHIPS - XML"of chipsxmltable1 x;)

    Output:
    --------

    CHIPS - XML
    -----------------
    NoNoYYYYYY


    To display the data in a tag with or without structure (which does work) using the function "EXTRACT":
    -------------------------------------------------------------------------------------------------------------

    6.query:
    ---------

    Select extract (XMLDATA, "/Field1/text()').getstringval()"XMLDATA' chipsxmltable1 x;

    Select extract (XMLDATA, "/Field1/UTI').getstringval()"XMLDATA' chipsxmltable1 x;

    Select extract (XMLDATA, "/Field1/UTI/U01').getstringval()"XMLDATA' chipsxmltable1 x;

    Select extract (XMLDATA, "/Field1/UTI/U01/text()').getstringval()"XMLDATA' chipsxmltable1 x;


    Output:
    --------

    CHIPS - XML
    ---------------------------------------



    The queries above are not fetch the value.



    To display the data in a tag with or without structure (which does work) using the function "EXTRACTVALUE":
    ------------------------------------------------------------------------------------------------------------------

    7 query:
    ----------

    Select extractValue (XMLDATA, ' / Field1/UTI ') 'XMLDATA' of chipsxmltable1 x;

    Select extractValue (XMLDATA, ' / U01/UTI/Field1 ') 'XMLDATA' of chipsxmltable1 x;


    Output:
    --------

    X
    -



    The queries above are not fetch the value.


    My question is:
    --------------------
    How to extract the values of xml tag when the value are inserted through xml schema?


    My apologies if the description is not clear. Kindly let me know if further details are required. Thanks a lot for your help.

    Very cordially,
    Godwin Castro C.V.

    Hello

    You must declare the namespace of each element used in the XPath expression, like this:

    SQL> select extractvalue( XMLDATA
      2                     , '/samp:Field1/UTI/U01'
      3                     , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' ) "XMLDATA"
      4  from chipsxmltable1 x
      5  ;
    
    XMLDATA
    --------------------------------------------------------------------------------
    No
     
    
    SQL> select extract( XMLDATA
      2                , '/samp:Field1/UTI'
      3                , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"'
      4                ).getstringval() "XMLDATA"
      5  from chipsxmltable1 x
      6  ;
    
    XMLDATA
    --------------------------------------------------------------------------------
    
      No
      Y
      Y
      Y
      Y
      Y
      Y
      Y
    
     
    

    Please see EXTRACT and EXTRACTVALUE documentation:
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions051.htm#i1006712
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions052.htm#SQLRF06173

    BTW, 'XMLDATA' is a pseudo-column used by Oracle. I don't know if it will never cause any conflict, but perhaps you need to rename your column.
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/pseudocolumns010.htm#SQLRF00256

    Kind regards.

  • How to extract the node where the value of the node is the max in all of the XML document?

    Hello

    I have a transaction that refers to an xmltype in iRecruitment, containing multiple versions of the same node as follows:

    (only for the example data)



    {noformat} & lt; Transaction & gt;


    & lt; data & gt;


    & lt; ObjectVersionNumber & gt; 1 & lt; / object_version_number & gt;


    & lt; EO & gt;


    & lt; Attribute1 & gt; A & lt; / Attribute1 & gt;


    & lt; Attribut2 & gt; B & lt; / attribut2 & gt;


    & lt; /EO & gt;


    & lt; / data & gt;


    & lt; data & gt;


    & lt; ObjectVersionNumber & gt; 2 & lt; / object_version_number & gt;


    & lt; EO & gt;


    & lt; Attribute1 & gt; A & lt; / Attribute1 & gt;


    & lt; Attribut2 & gt; C & lt; / attribut2 & gt;


    & lt; /EO & gt;


    & lt; / data & gt;


    & lt; data & gt;


    & lt; ObjectVersionNumber & gt; X & lt; / object_version_number & gt;


    & lt; EO & gt;


    & lt; Attribute1 & gt;? & lt; / Attribute1 & gt;


    & lt; Attribut2 & gt;? & lt; / attribut2 & gt;


    & lt; /EO & gt;


    & lt; / data & gt;


    & lt; / Transaction & gt; {noformat}

    I can extract a value for FULL-TIME 1 or 2, is not a problem.
    However, how can I go on the selection of a value of an attribute below FULL-TIME X, where X is the maximum value of FULL-TIME in any node in the XML document?

    I tried to the last node corresponding to my way, but it is not always the case that the FULL-TIME max will correspond to this scenario.

    Any help would be greatly appreciated!

    Thank you very much, Pete

    Published by: Pete Mahon on February 24, 2009 12:11

    Here's a way

    SQL> set long 100000
    SQL> with XML as (
      2  select XMLTYPE(
      3  '
      4  
      5     
      6             1
      7             
      8                     A
      9                     B
     10             
     11     
     12     
     13             2
     14             
     15                     A
     16                     C
     17             
     18     
     19     
     20             3
     21             
     22                     ?
     23                     ?
     24             
     25     
     26  ') OBJECT_VALUE
     27    from dual
     28  )
     29  select DATA, OVN
     30    from XML,
     31         XMLTable
     32         (
     33           '/Transaction/data'
     34           passing OBJECT_VALUE
     35           columns
     36           DATA XMLType path '.',
     37           OVN  number  path 'ObjectVersionNumber'
     38         )
     39   where OVN = ( select MAX(OVN)
     40                   from XML,
     41                        XMLTable
     42                        (
     43                          '/Transaction/data'
     44                          passing OBJECT_VALUE
     45                          columns
     46                          OVN  number  path 'ObjectVersionNumber'
     47                        )
     48               )
     49
    SQL> /
    
    DATA
    --------------------------------------------------------------------------------
           OVN
    ----------
    3?
    ?
             3
    
    SQL>
    
  • Extract the value of an xml file (LPX-00601: invalid token)

    Hello

    I have this kind of XML / example...

    declare
        l_clob clob;
        l_xml xmltype;
    
    
    begin
        l_clob := '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fu="http://www.fu.gov.si/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Body>
            <fu:BusinessPremiseResponse Id="data">
                <fu:Header>
                    <fu:DateTime>2015-10-02T10:56:40.416Z</fu:DateTime>
                    <fu:MessageID>2107C422-FC85-291C-E053-0CC910AC3C4F</fu:MessageID>
                </fu:Header>
                <fu:Error>
                    <fu:ErrorCode>S001</fu:ErrorCode>
                    <fu:ErrorMessage>eriworwiweorioweriorio</fu:ErrorMessage>
                </fu:Error>
            </fu:BusinessPremiseResponse>
        </soapenv:Body>
    </soapenv:Envelope>
    ';
     l_xml := xmltype(l_clob);
      put_xl_line(l_xml.extract('/soapenv:Envelope/soapenv:Body/fu:BusinessPremiseResponse/fu:Error/fu:ErrorCode/text()','xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"').getStringVal());
    
    end;
    

    what I want is to extract the /soapenv:Envelope / soapenv:Body / fu:BusinessPremiseResponse / fu:Error / fu:ErrorCode

    I get this kind of error:

    ORA-31011: XML parsing failed

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

    LPX-00601: token not valid in: ' / soapenv:Envelope / soapenv:Body / fu:BusinessPremiseResponse / fu:Error / fu:ErrorCode / text () '

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

    ORA-06512: at line 23

    Thank you

    Hi Peter,.

    What is your version of db?

    EXTRACT and related functions are all deprecated from 11.2.

    Use XMLTABLE or XMLQUERY.

    About the error:

    You have the XPath to the right, but missing the mapping prefix of "fu":

    (l_xml). Extract

    ' / soapenv:Envelope / soapenv:Body / fu:BusinessPremiseResponse / fu:Error / fu:ErrorCode / text () '

    "', ' xmlns:soapenv ="http://schemas.xmlsoap.org/soap/envelope/"

    xmlns:Fu ="http://www.fu.gov.si/" "."

    )

    Example with XMLTABLE:

    declare
      l_clob        clob;
      l_error_code  varchar2(30);
    begin
      l_clob := '
        
            
                
                    2015-10-02T10:56:40.416Z
                    2107C422-FC85-291C-E053-0CC910AC3C4F
                
                
                    S001
                    eriworwiweorioweriorio
                
            
        
    ';
    
      select errorcode
      into l_error_code
      from xmltable(
             xmlnamespaces(
               'http://schemas.xmlsoap.org/soap/envelope/' as "env"
             , default 'http://www.fu.gov.si/'
             )
           , '/env:Envelope/env:Body/BusinessPremiseResponse/Error'
             passing xmlparse(document l_clob)
             columns errorcode varchar2(30) path 'ErrorCode'
           ) ;
    
      dbms_output.put_line(l_error_code);
    
    end;
    /
    

Maybe you are looking for

  • HP DV6871US infrared remote not working do not on Windows 7 (32 bit)

    It comes to my laptop. It's the distance in question: I have Windows 7 Ultimate (32 bit) installed. I used Windows Update and that fixes almost all driver problems. Page for this laptop to official HP support said that there is not any drivers for th

  • error "Ibsta" no was not declared in this scope

    I have a "error: 'Ibsta' was not declared in this scope." I try to program with C++ and GPIB test equipments, but so far, I have this problem. I'm sorry, but my knowledge of C++ is very limited because I took a module on it for about 4 months in Coll

  • How to determine the E4200 V1 or V2?

    Pages support and registration for the E4200 wireless router ask if I have a router V1 or V2. There is no place on the real router which identify it as V1 or V2, and Cisco Connect app does not display this information. What I know is the following: M

  • How to enable recent items on jump list

    Not sure if it of a problem or not. I would like a list of recent items on my list of jump (in fact, only for MS Word) in the task bar. I only have pinned files, but would like to be able to place a file in the list of recent files and PIN which as w

  • Question of crossed

    I'm sure this has been asked, but I'm not. I have my users connecting to my office (Site A in the diagram) using the Cisco VPN client. I also have my office connected to another (site B) via an IPSec tunnel. It all works very well. What I want to do