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.

Tags: Database

Similar Questions

  • Another REGEXP question: how to extract multiple values from a string

    Hi, how can I retrieve multiple values to a string with RegExp with Oracle SQL constructs?

    Have looked at the various examples, I cannot understand this.
    the following Sql code
    select
       regexp_substr(sessie."rollen", 'CN=A_role') "A_role"
       from ( 
    select '
    CN=A_role,OU=a_org_unit,OU=another_org_unit,DC=bz,DC=ad,DC=min,DC=local
    CN=Another_role,OU=some_org_unit,DC=bz,DC=ad,DC=min,DC=local
    CN=Users,OU=Dep,DC=bz,DC=ad,DC=min,DC=local
    '   "rollen" from dual
    ) sessie;
    Returns CN = A_role.
    I want him back all of the CN = concatenated values with a semicolon and stripped of the CN = bit.
    So: A_role; Another_role; Users .

    Any help would be much appreciated. Here I use database 11g 11.2.0.2.0.

    Does anyone have an idea how to do this in SQL?

    best regards Mike

    Hello
    If using Oracle 11 g

    with tst
      as (select   'CN=A_role,OU=a_org_unit,OU=another_org_unit,DC=bz,DC=ad,DC=min,DC=local,'
                 ||'CN=Another_role,OU=some_org_unit,DC=bz,DC=ad,DC=min,DC=local,'
                 ||'CN=Users,OU=Dep,DC=bz,DC=ad,DC=min,DC=local' as rollen
            from dual
          )
    select listagg(sub, ',') within group (order by rn) as res
      from (select regexp_substr(rollen, '(CN=)([[:alnum:]_]+)',1,rownum,'i',2) sub, rownum rn
              from tst
           connect by level <=length(rollen)
           )
     where sub is not null       
    
  • Extract the value of an xml file-

    Hello
    I have a requirement that needs to store the contents of the XML db tables. Here I give you the details of the sample, it must extract values from the XML file and place these values in the mapping table.

    Sample:

    I created a table - create the table txt_xml of xmltype.

    insert into table txt_xml values (xmltype ('))
    < NewDataSet >
    "" < DerivativeSecurity FAS157Level = "3" FAS157MVAdjustable = "N" OriginalMV = FAS157MVDelta "573174.3253" = "0.0" FAS157AdjustedMV = "573174.3253" PLCurrency = "USD" DerivativeSecurityID = "2009-BFWD-0001TRD' MetDerivativeID = '2009-BFWD-0001' MurexTransactionNumber = '36319' Trader '_GTELL' BuySell = =" B "DetailType = 'TRD' DerivativeType = 'BFWD' AL_ManagementSide = 'Active' CounterpartyCode = '3045' CounterpartyName =" ' JPM / CHASE "CurrencyCode ="USD"Coupon ="0,0"FixedFloatingIndicator ="FIXRT"IndexMultiplier ="1.0"IndexName = 'Bond' ="0,0"Comment11 = margin" PCG 6.05 01 / 03 / 34 "Comment12 ="2009-BFWD-0001"Comment13 ="694308GE1"Comment21 =" "Comment22 = Comment23"83003169"="1 618 300"TradeComment =" are created-credit of the assets for the current article "" specific - anticipation Hedge - PCG FWD 6.05% 01/03/2034. Are created. "" "" "" - Original M"OptionCallPut =" "OptionType =" "SettleType = 'Cash' RefISIN =" "RefObligation =" "sensitivity ="15044.6506"EffectiveConvexity ="0,0"Vega ="0,0"NextResetDate =" "LastResetDate =" "EffectiveDuration ="13.9289"Instrument"Bond"IssuerCode ="19039"IssuerName = ="PACIFIC GAS' IssuerREDCode '6FD738' strategy = = "CRD-PROT-07" StrikePrice = MaturityDate '105.89' = "TickerSymbol =" 2010-01-04 "" "MetPay =" "MetRec =" "Payrec =" P "RiskSection =" "HedgedItem =" deadline specific asset "ResetFrequency =" "ResetFrequencyNumber =" "PaymentFrequency =" "PaymentFrequencyNumber =" "CapFloorCoupon ="0.0"RefIndexRate ="0,0">"
    < name of classification = "XHSEC" Value = "Derivatives" ValueDescription = "950" / >
    < name of classification = "XSEC" ValueDescription = 'Credit' Value = '430' / >
    < name of classification = "XLEV1" ValueDescription = value 'Before' = "9400" / >
    < name of classification = "XLEV2" ValueDescription = 'Hedge' Value = "150000" / >
    < / DerivativeSecurity >
    ((< / NewDataSet > '));

    now what I need is OriginalMV value of this XML field. Please help me

    Published by: Govind2 on February 5, 2010 08:33

    Yes it will fail because error explains everything... excerpt from value does not return several values for a simple xpath...

    so in this case you must use the function xmltable...

     SELECT column_value
       FROM some_things v,
      xmltable('for $i in /NewDataSet/DerivativeSecurity return $i/@FAS157Level' passing value(v))
    

    edit your table name in the code above... and confirm

    Ravi Kumar

  • Return multiple values from a table

    Hi there I'm working on a bit of sql that returns values when they exist in a table.
    The code I have returns the correct value when there is an entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it does display no line at all: (.)

    Can someone tell how to return multiple values?

                 select modulename from tbl_modulefeedback
    where 1 = (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    Thanks in advance!

    Ashleigh

    Try this:

    select modulename
    from tbl_modulefeedback
    where 1 <= (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 <= (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    

    When you ask questions, please enter CREATE TABLE and INSERT some commands to make it easier to help you.

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • 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>
    
  • 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;
    /
    
  • Extract the value between the xml tags in the XML inside the BLOB field

    Hello

    I have a table that contains a BLOB column, this XML file to store column that received from an external source. Now for one of my needs. I need to read that value is the specific XML tag and create the entry in the database.

    Column name DataType
    IDNumber
    RecordBLOB OBJECT

    This is the XML code that is stored in the file inside the BLOB field format. XML below, I need go get AMC1234 there is after < itemName > text < / itemName > I thought to use XMLTYPE, but unfortunately my DBA team does not XML database, I now use UTL_RAW. CAST_TO_VARCHAR2 and recovery entire string, but I am not able to read actual result it takes. Can someone help me remove AMC1234.

    <? XML version = "1.0"? >

    <! DOCTYPE importFile SYSTEM "xyz.dtd" >

    -< importFile >

    -< importResult >

    < mode status = "DΘFINIR" > general failure < / status >

    < statusCode > 1 < / statusCode >

    invalid < errorMsg > list and holiday component < / errorMsg >

    -< returnInfo >

    < itemName > PRQ < / itemName >

    < Valeurelement > CBA < / Valeurelement >

    < / returnInfo >

    -< returnInfo >

    < itemName > LMP < / itemName >

    < Valeurelement > CBA < / Valeurelement >

    < / returnInfo >

    -< returnInfo >

    < itemName > KEY < / itemName >

    < Valeurelement > 9999 < / Valeurelement >

    < / returnInfo >

    -< returnInfo >

    < itemName > text < / itemName >

    < Valeurelement > AMC1234, FIXED_ALL, RED < / Valeurelement >

    < / returnInfo >

    < / importResult >

    < / importFile >


    Thank you

    Without

    Without - try something like...

    with t as (select"

    -

    -

    General failure

    1

    component and invalid vacation list

    -

    PRQ

    ABC

    -

    LMP

    ABC

    -

    KEY

    9999

    -

    Text

    AMC1234, FIXED_ALL, RED

    "the double pass."

    )

    Select Replace (regexp_substr (col,'([^<>']) itemName))

    , replace (regexp_substr (col,'([^<>""]) Valeurelement))

    t

    connection of level <=> ');

  • 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.

  • Extraction of data from a XML and inserting into a table

    Hi all

    I have a problem for which I couldn't find any convincing solution

    I have an XML format

    <data>
    <students>
    <student>
    <studentname>Raymond<studentname>
    <StudentId>1</StudentId>
    <StudentAge>11</StudentAge>
    <StudentMark>0</StudentMark>
    </student>
    </students>
    
    
    

    Now I have to insert this XML DB, the table consists of the following columns

    (line number, property name, value)

    Wait it out put is

    (1, studentname, Raymond).

    (1, studentid, 1)

    (1, studentAge, 11)

    (1, Studentmark, 0)

    The challenge here

    1. how to get the tag names and fill in the property name column?

    2. the number of properties for a student can be variable, how can I deal with them?

    I am very new to PLSQL XML manipulation. Can someone give me some advice I can start with the creation of a solution?  I hope, I've been able to describe my use case. If this isn't the case, please let me know.

    Thanks in advance,

    Cherif

    Here is an example:

    SQL > with sample_data like)

    2. Select xmlparse (document

    3'

    4

    5

    6 Raymond

    7        1

    8        11

    9        0

    10

    11

    12 John

    13        2

    14        18

    15        15

    16

    17

    18 ') xmldoc

    19 of the double

    20)

    21 select x1.record_id

    22, x2.*

    sample_data 23 t

    24, xmltable)

    25 ' / data/students/pupils.

    26 passage t.xmldoc

    record_id 27 columns for ordinalite

    28, property xmltype path ' *'

    (29) x 1

    30, xmltable)

    31         '*'

    32 passage x1.properties

    path of varchar2 (30) 33 columns property_name "local - name (.)".

    34, path name varchar2 (30) '.'

    (35) x 2

    36;

    RECORD_ID PROPERTY-NAME NAME

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

    1 studentname Raymond

    StudentId 1 1

    1 StudentAge 11

    1 StudentMark 0

    2 John studentname

    StudentId 2 2

    2 StudentAge 18

    2 StudentMark 15

    8 selected lines

  • passing multiple values from the query in the select statement of the procedure

    I am collecting IDS to select education agreement from the date of rental values and then I would pass the result of the query in the statement select to get the result.
    data type for the contract id is of type varchar and date of rental there is more than one id to contract for most of the time. Help, please. Thank you

    CREATE OR REPLACE PROCEDURE abstract_menu (p_letting   IN     VARCHAR2,
                                               p_results      OUT SYS_REFCURSOR)
    IS
       v_contractId   VARCHAR2 (40);
    
    SELECT lcontid
      INTO v_contractId
      FROM letprop
     WHERE datestat IS NOT NULL AND letting = p_letting AND letstat <> 'R';
    
    
    BEGIN
       OPEN p_results FOR
            SELECT DISTINCT
                      SUBSTR (l.letting, 3, 2)
                   || '-'
                   || SUBSTR (l.letting, 5, 2)
                   || '-'
                   || SUBSTR (l.letting, 1, 2)
                      lettingdate,
                   l.lcontid contractid,
                   SUBSTR (q.cprojnum, 1, 10) projectnumber,
                   DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route)))
                      routenumber,
                   L.DATESTAT statusdate,
                   L.LETSTAT lettingstatus,
                   (q.cdescr) jobdescription,
                   INITCAP (q.clocat1 || q.clocat2) LOCATION
              FROM vendor v,
                   vendaddr r,
                   letprop l,
                   planhold p,
                   proposal q,
                   project j,
                   propproj k,
                   bidlet bd
             WHERE     v.vendor = r.vendor
                   AND k.contid = q.contid
                   AND k.pcn = j.pcn
                   AND l.lcontid = k.contid
                   AND p.vendor = v.vendor
                   AND l.letting = p.letting
                   AND l.lcontid IN v_contactid  "**************This is where I would like to pass the contract id from the above select statement***********'"
                   AND l.CALL = p.CALL
                   AND r.addrnum = p.billto
                   AND bd.letting = l.letting
          GROUP BY q.cdescr,
                   q.clocat1,
                   q.clocat2,
                   bd.letting,
                   l.letting,
                   l.lcontid,
                   q.cprojnum,
                   L.LETSTAT,
                   L.DATESTAT
          ORDER BY lettingdate;
    
    end;

    user9196150 wrote:
    AND l.lcontid IN v_contactid ' * this is where I would like to pass the id of the select statement above contract * ""»

    CREATE OR REPLACE PROCEDURE abstract_menu (p_letting   IN     VARCHAR2,
                                               p_results      OUT SYS_REFCURSOR)
    IS
    BEGIN
       OPEN p_results FOR
            SELECT DISTINCT
                      SUBSTR (l.letting, 3, 2)
                   || '-'
                   || SUBSTR (l.letting, 5, 2)
                   || '-'
                   || SUBSTR (l.letting, 1, 2)
                      lettingdate,
                   l.lcontid contractid,
                   SUBSTR (q.cprojnum, 1, 10) projectnumber,
                   DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route)))
                      routenumber,
                   L.DATESTAT statusdate,
                   L.LETSTAT lettingstatus,
                   (q.cdescr) jobdescription,
                   INITCAP (q.clocat1 || q.clocat2) LOCATION
              FROM vendor v,
                   vendaddr r,
                   letprop l,
                   planhold p,
                   proposal q,
                   project j,
                   propproj k,
                   bidlet bd
             WHERE     v.vendor = r.vendor
                   AND k.contid = q.contid
                   AND k.pcn = j.pcn
                   AND l.lcontid = k.contid
                   AND p.vendor = v.vendor
                   AND l.letting = p.letting
                   AND l.lcontid IN (
                                     SELECT  ll.lcontid
                                       FROM  letprop ll
                                       WHERE ll.datestat IS NOT NULL AND ll.letting = p_letting AND ll.letstat  'R'
                                    )
                   AND l.CALL = p.CALL
                   AND r.addrnum = p.billto
                   AND bd.letting = l.letting
          GROUP BY q.cdescr,
                   q.clocat1,
                   q.clocat2,
                   bd.letting,
                   l.letting,
                   l.lcontid,
                   q.cprojnum,
                   L.LETSTAT,
                   L.DATESTAT
          ORDER BY lettingdate;
    
    end;
    /
    

    SY.

  • Get unique values from an xml table

    I have an xml file and I would like to create a table of all the unique values of one of its nodes.

    The xml file is called pntxml and the node is pntxml.row.Category where the category is where I would like to create a table of all the unique values.

    I was working through this and would first create an array of all the values in the category in iterating through the xml and pushing these values in a separate table.  When I try to push each entry in a table I get an error or

    TypeError: Error #1009: cannot access a property or method of a null object reference.
    at NAPA_fla::MainTimeline/sortXml()

    var catArray:Array;
    
    function sortXml(event:Event):void{
    for (var i:int = 0; i< pntxml.row.length(); i++){
         tmpCat=pntxml.row[i].Category;
         trace(tmpCat);
            catArray.push(tmpCat);           
    }
    }
    

    Anyone has a suggestion for the best way to get at this problem?

    Thanks in advance,

    Josh

    Your catArray does not exist because you said only she, you have not created an instance of this...

    var catArray:Array = new Array();

  • getting a value from an XML string

    If I want a loader to load a text file based on XML how I'd get the XML to return a string.


    The first lines of code are my xml file.
    The following code excerpt is my charger of xml.
    The last code snippet is where I want my text file to load.
    In my line of code which is: myLoadVar.load (t.content); How can I get the value of t.content I got an xml file for a file name? I think I should do my xml file returns a string.

    You must add a line of code. I need to see the where it is located, in the lines below.

  • want to extract two values from rows in a single sql result

    Let me first of all explain the situation

    I have two tables
    1 Animal_details(animal_id,and other details)
    2 Animal_weight(animal_id,seq_no,weight,date_weighed)

    in fact situation here is that for each weight I am inserting a new line with seq_no say
    1 for the first weight
    2 for the second weight...
    with their weight and date
    for example. animal_id = 1 seq_no = 1, weight = 200, date_weighed = 12-may-2000;
    animal_id = 1, seq_no = 2, weight = 250, date_weighed = June 12, 2000;

    means seq_no = 1 represents 1 weight of animals
    seq_no = 2 represents 2 weight of animals

    how an animal can have any number. weighted times.

    now what I want, I want to show a result with

    animal_id, weight_1, weight_2 with other animals details in a single line

    How can I get first weight and the second or more weight in the same line for any animal?

    Please answer soon, its urgency.

    Thank you

    You cannot issue a SQL with dynamic column list of 100%. What you can do is something like the questions:

    with t as (
               select  animal_id,
                       max(case seq_no = 1 then weight end) first_weight,
                       max(case seq_no = 2 then weight end) second_weight,
                       max(case seq_no = 3 then weight end) third_weight
                 from  animal _weight
                 where seq_no <= 3
                 group by animal_id
              )
    select  t1.animal_id,
            first_weight,
            second_weight,
            third_weight,
            other_details
      from  t t1,
            animal_details t2
      where t2.animal_id = t1.animal_id
    /
    

    SY.

  • 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.

Maybe you are looking for