The value of xml type column in oracle database 11 g 2

I have a table containing columns XMLtype as 'XML_TABLE (ID NUMBER, donnees_xml XMlTYPE).

Then I insert a value such as

INSERT INTO xml_table (1, XMLtype('<current>
      <city id="2643743" name="London">
        <coord lon="-0.13" lat="51.51"/>
        <country>GB</country>
        <sun rise="2015-03-04T06:38:20" set="2015-03-04T17:46:01"/>
      </city>
      <temperature value="280.71" min="280.15" max="281.15" unit="kelvin"/>
      <humidity value="77" unit="%"/>
      <pressure value="1029" unit="hPa"/>
    </current>'));


Now, I want to ask about this table. I can easily choose 'country' with the following query

select t.xml_data.extract('/current/city/country/text()').getStringVal() "XML Data"
from xml_table t;

But I can't select the value of the temperature by this query. Now how to select the value of the temperature of the table?

EXTRACT, EXTRACTVALUE etc are deprecated in 11.2.

Use instead the XQuery functions.

If you need to retrieve several values, XMLTABLE will be good:

SQL> alter session set nls_numeric_characters = ".,";

Session altered.

SQL>
SQL> select x.*
  2  from xml_table t
  3     , xmltable(
  4         '/current'
  5         passing t.xml_data
  6         columns country     varchar2(10) path 'city/country'
  7               , temperature number       path 'temperature/@value'
  8       ) x
  9  ;

COUNTRY    TEMPERATURE
---------- -----------
GB              280.71

Tags: Database

Similar Questions

  • To have the value 'All' in the list of elements of control in the value of array type

    Hi all

    To have the value 'All' in the list of master points.
    Need to create a set of value that shows the items in the inventory template and append the value 'All' in the list, so that the user can select.

    I have the below query that does this. But how can I highlight the value of table type.

    SELECT ItemList segment1
    OF MTL_SYSTEM_ITEMS_B
    WHERE organization_id = 0
    UNION ALL
    SELECT 'All' ItemList
    OF the double

    Please do the needful.

    Thank you.

    Hello
    One way to do, is to create a database for you view query and base your value set on this point of view.
    Hope this helps,
    J.

  • The CPU is not powerful enough for Oracle database 11g?

    The CPU is not powerful enough for Oracle database 11g?

    I installed the datatase Oracle 11 g on my host by using the default configuration of oracle yesterday. Today, I find some the alert message: "CPU usage is 86,79%, through attention (80) or critical (95) threshold.» The average value of the CPU usage is 80.85% and I have to wait for more than 10 seconds for opening a page of the EM.
    My host is HP workstation xw4200. CPU is 3.4 GHz. No other applications on that host.
    I want to know: what is the main reason for the shortage of CPU resources? Because the database Oracle 11g itself is exhausting CPU or because there are a few configuration issues?

    qkc wrote:
    1 is it true that most of the CPU is exhausted by the EM control tool?

    It's quite possible.

    It is also one of the reasons why we encourage people to drop EM Database Console and switch to EM Grid Control. The burden is then on another server.

    2. why this index has been added in advance by Oracle Corporation? It does not seem that each tool is set up perfectly in advance.

    It was probably not required under ideal conditions, in which it has been designed and tested.

    Why is your environment not identical to the designed conditions that use Oracle? ;-)

  • Retrieves the values of XML based on filters

    I am new to use XML with oracle. This is a sample XML from an XML file, now the question is it really possible to write sql queries to extract based on a result, that is to say, if I do a clip like this extract(column_name,//Requests//RequestBody//Item//ItemHeader//ItemAction/text(),).getStringVal () then I results XL1XL2 what I need exactly is only "ItemAction" XML member value when the value is = 'Add '. which means that the final result value, I need XL1. Please note that the values I gave ablove XL1 and XL2, is flexible, that is, sometimes, it's XLLL1 some time XL1, so can't go based on the use of SUBSTR function to extract a fixed value.

    < ns3:Requests >

    < ns3:Request >

    < ns3:RequestBody >

    < ns3:Item >

    < ns3:ItemHeader >

    < ns3:ItemId > 99 < / ns3:ItemId >

    < ns3:ItemType > TypItem < / ns3:ItemType >

    < ns3:ItemAction > Add < / ns3:ItemAction >

    < / ns3:ItemHeader >

    < ns3:ItemBody >

    < ns3:ServiceItem >

    < ns3:ServiceCode > XL1 < / ns3:ServiceCode >

    < / ns3:ServiceItem >

    < / ns3:ItemBody >

    < / ns3:Item >

    < ns3:Item >

    < ns3:ItemHeader >

    < ns3:ItemId > 100 < / ns3:ItemId >

    < ns3:ItemType > TypItem < / ns3:ItemType >

    < ns3:ItemAction > Remove < / ns3:ItemAction >

    < / ns3:ItemHeader >

    < ns3:ItemBody >

    < ns3:ServiceItem >

    < ns3:ServiceCode > XL2 < / ns3:ServiceCode >

    < / ns3:ServiceItem >

    < / ns3:ItemBody >

    < / ns3:Item >

    < / ns3:RequestBody >

    < / ns3:Request >

    < / ns3:Requests >

    As I understand it, you want to return the code of service elements where the ItemHeader = "add"?  Note: You have missed your name space in the XML document, so I added a.

    with data (the_xml) as)

    Select xmltype (')

    99

    TypItem

    Add

    XL1

    100

    TypItem

    Delete

    XL2

    ')

    of the double

    )

    Select x.*

    data d

    Join the xmltable (xmlnamespaces ('somenamespace "like" ns3 "),)

    "' ns3:Requests / ns3:Request / / ns3:RequestBody / / ns3:Item [ns3:ItemHeader / ns3:ItemAction ="Add"]"

    in passing d.the_xml

    columns

    Path of varchar2 (20) conduitePlan ' ns3:ItemBody / ns3:ServiceItem / ns3:ServiceCode'

    ) x 1 = 1

    RESULT

    CONDUITEPLAN

    'XL1 '.

  • Is there anyway to save the output of the OPA in XML if we use Oracle Web determinations

    Team,

    Can you please help on the scenario below.

    We use clouds OPA August version 12.2. We develop the application assistant job using determinations OPA Web to capture trade information and the information of the Agency cross.

    Instead of the page summary integrated OPA, we plan to create the PHP to capture from the OPA interview Assistant business page.

    Is there a way to capture the output of the OPA in XML format to send it to the contents of PHP page?

    If someone falls on this scenario, please share your entries with small example.

    Appreciate your help.

    Thank you

    Vivek

    Managers of custom control are documented here library of Documentation Oracle policy Automation.

    The Manager of your custom control will get an HTTP POST request with several parameters which will be takeover-session. The value of this parameter is a URL string coded something like this:

    opa-session=%3C%3Fxml+version%3D%221.0%22+%3F%3E%3Csession-data+xmlns%3D%22http%3A%2F%2Foracle.com%2Fdeterminations%2Fengine%2Fsessiondata%2F10.2%22%3E%3Centity+id%3D%22global%22%3E%3Cinstance+id%3D%22global%22%3E%3Cattribute+id%3D%22nearest_city%22+type%3D%22text%22+inferred%3D%22false%22%3E%3Cunknown-val%2F%3E%3C%2Fattribute%3E%3Cattribute+id%3D%22gps_coords%22+type%3D%22text%22+inferred%3D%22false%22%3E%3Cunknown-val%2F%3E%3C%2Fattribute%3E%3Cattribute+id%3D%22number_vehicles%22+type%3D%22text%22+inferred%3D%22false%22%3E%3Cunknown-val%2F%3E%3C%2Fattribute%3E%3C%2Finstance%3E%3C%2Fentity%3E%3C%2Fsession-data%3E

    and when decoded will be:

    http://Oracle.com/determinations/engine/sessiondata/10.2">

    You can analyze using some PHP for the analysis of the structures of XML.

  • What SYS tables (not seen) contains the value NULL spec /not/ column definition?

    What SYS (or tables) store the value of a spec /not/ NULL columns? (It doesn't seem to be COL$)

    NOTE: This is NOT a trick question - although it seems to be.

    Test configuration:
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Test configuration:
    1. a table is created by SCOTT in the SCOTT schema with a NULLABLE column.

    2. a primary key constraint is added using only the NULLABLE column

    3. Requests for information on USER_TAB_COLS, ALL_TAB_COLS, DBA_TAB_COLS and SYS. COL$ see NOT NULL for the column NULLABLE
    as necessary for a primary key constraint. Views derive their data from the column of $ NULL the sys. Table of $ COL
    using
    'DECODE (SIGN (c.null$), -1, 'D', 0, 'Y', 'N'),
    and the table of $ COL shows a numerical value of '0' before you add the primary key and a value of "1" later.

    4. a query on the DDL metadata table shows the specification for column NULLABLE of origin involved.

    Question - where this original specification NULLABLE is stored?

    This question is based on a question asked by another user in this thread
    Columns becoming nullable after a fall of primary key?

    I created the following specially for that matter test case
    -- scott ensures table does not exist
    DROP TABLE tbl_test CASCADE CONSTRAINTS;
    
    -- scott creates a table
    CREATE TABLE tbl_test ( col_1 NUMBER,
    col_2 NUMBER NOT NULL);
    
    -- scott queries to check the the column nullable status
    SELECT table_name, column_name, nullable 
    FROM user_tab_cols
    WHERE table_name = 'TBL_TEST';
    
    -- TABLE_NAME | COLUMN_NAME | NULLABLE
    -- TBL_TEST   | COL_1       | Y 
    -- TBL_TEST   | COL_2       | N 
    
    -- Scott addes a primary key constraint using only the nullable column
    ALTER TABLE tbl_test ADD CONSTRAINT tbl_test_pk PRIMARY KEY(col_1);
    
    -- scott queries to check the the column nullable status
    SELECT table_name, column_name, nullable 
    FROM user_tab_cols
    WHERE table_name = 'TBL_TEST';
    
    TABLE_NAME,COLUMN_NAME,NULLABLE
    TBL_TEST,COL_1,N
    TBL_TEST,COL_2,N
    
    -- scott queries to get the table DDL
    select dbms_metadata.get_ddl('TABLE', 'TBL_TEST', 'SCOTT') FROM DUAL;
    
    DBMS_METADATA.GET_DDL('TABLE','TBL_TEST','SCOTT')
    
      CREATE TABLE "SCOTT"."TBL_TEST" 
       (     "COL_1" NUMBER,                   <------ where is this NULLABLE spec stored? 
         "COL_2" NUMBER NOT NULL ENABLE, 
          CONSTRAINT "TBL_TEST_PK" PRIMARY KEY ("COL_1")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS NOCOMPRESS LOGGING
      TABLESPACE "USERS"  ENABLE
       ) SEGMENT CREATION DEFERRED 
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      TABLESPACE "USERS" 
    The DOF shows that Oracle keeps the original spec NULLABLE for the column and uses it to generate the DDL orginal, even if there is a primary key on the table and the system views (and COL$) show the column non NULLABLE.

    So where is the original information NULLABLE actually stored?

    rp0428 wrote:
    What SYS (or tables) store the value of a spec /not/ NULL columns? (It doesn't seem to be COL$)

    I think that it becomes a bit messy depending on order of activity:

    You can see Col. .null$ is set to a non-zero when the desrcibe command displays the column as not null, but it can happen for two reasons:
    (a) user sets the column as not null - in which case you get a line in cdef$ with type # = 7
    (b) the user adds a primary key to table - in which case you get a line in cdef$ with type # = 2

    If you declare null AND add a primary key, you get two lines - that's why it is possible for Oracle to determine if he should remove the flag not null when you remove the primary key and also allows dbms_metadata show the create statement of table without a NOT NULL even when describe it the watch with a NOT NULL - dbms_metadata can respond to the presence of the type # = 2 and absence of the type # = 7.

    Concerning
    Jonathan Lewis

    By the way: by a strange coincidence, it seems to me answering the previous post, three days before it was asked: http://jonathanlewis.wordpress.com/2012/04/19/drop-constraint/#comment-46140 (on the doubts, this isn't - it answers a different question on the removal of constraints).

    Published by: Jonathan Lewis April 23, 2012 11:07

  • find the value relative to another column

    Find the value column B in the column 'sparent. Let me explain the few cases:
    Suppose that we receive the 1000 kg of quantity for Jack, Jack then transferred this 1000 kg to Robin and Robin transferred once again this amount to Parkins and so on. A column named Type records the entry type, either it's a receipt or transfer operation. His entry would be recorded in my table like:

    QTY_ A_ B_ Type_
    Reception of 1000 Jack
    1000 jack Robin transfer
    Transfer of 1000 Robin Parkins

    So, with this information, you find the parent of Parkins, Jack, receipt of Type?
    with t as (select 1000 qty,null a,'jack' b,'receipt' type from dual
                 union all
                   select 1000,'jack','robin','transfer' from dual
                   union all
                   select 1000,'robin','','transfer' from dual
                   union all
                   select 1000,'parkins','jack','transfer' from dual)
        select *
          from t
          where connect_by_isleaf = 1
          and a is null
          connect by nocycle b = prior a
         start with b = 'jack' ;
    
           QTY A       B     TYPE
    ---------- ------- ----- --------
          1000         jack  receipt
    1 row selected.
    

    Good bye
    DPT

  • Read the value of XML or JSON based on the name of the key

    I can't figure out how to get the value of the url to Image_Calendar1 JSON or XML data.  Sorry if it's 'obvious', but I am a new developer.

    I was cheating and ListItemData.value [1] .url but in this case, that the XML feed changes the number values of the moments which throws out of my method.  I need to be able to get the value based on the name of the key.  Is this possible?

    Thank you. Examples of the XML and the JSON /port.

    Okay, it might not be pretty, but what I do to solve my problem is to convert the ListItemData in JSON and stringify it.  I then split the string with 'key' and then count the lines.  Would not work if 'key' wasn't in each line, or if there are child elements of the child elements.  But... it works for me at the moment.  Future, me I hope, will be more intelligent and can fix it when it breaks.

    var testString = String (JSON.stringify (ListItemData))

    var javascriptcount = String (testString.split("key").length - 1).

    Console.log ("try to use the length:" + javascriptcount)

  • Divide the values of a single column into multiple values of columns

    I want that the values of the "col_val" column to divide into several values in the column

    Table1:

    Col_val Col1, Col2

    Code1 POINT 45

    L2 AB 45

    L1 POINT 45 OF

    Code2 CAB 61

    ABC 51 LABORATORY

    SSS LAB 45

    QQQ BED 123

    BBV COT 100

    FFF COT 444

    Output as expected:

    OUT1 out2 out3-out4, out5

    Code1 AB SSS

    L1

    Code2

    ABC

    QQQ

    BBV

    FFF

    Each line must contain the values corresponding to the Col2 values and each column must have the values in Col1, as illustrated above.

    SQL> with t
      2  as
      3  (
      4  select 'Code1' col_val, 'ITEM' col1, 45 col2
      5    from dual
      6  union all
      7  select 'L2' col_val, 'AB' col1, 45 col2
      8    from dual
      9  union all
     10  select 'L1' col_val, 'ITEM' col1, 45 col2
     11    from dual
     12  union all
     13  select 'Code2' col_val, 'CAB' col1, 61 col2
     14    from dual
     15  union all
     16  select 'ABC' col_val, 'LAB' col1, 51 col2
     17    from dual
     18  union all
     19  select 'SSS' col_val, 'LAB' col1, 45 col2
     20    from dual
     21  union all
     22  select 'QQQ' col_val, 'COT' col1, 123 col2
     23    from dual
     24  union all
     25  select 'BBV' col_val, 'COT' col1, 100 col2
     26    from dual
     27  union all
     28  select 'FFF' col_val, 'COT' col1, 444 col2
     29    from dual
     30  )
     31  select max(col1)
     32       , max(col2)
     33       , max(col3)
     34       , max(col4)
     35       , max(col5)
     36    from (
     37            select decode(col1, 'ITEM', col_val) col1
     38                 , decode(col1, 'AB'  , col_val) col2
     39                 , decode(col1, 'LAB' , col_val) col3
     40                 , decode(col1, 'CAB' , col_val) col4
     41                 , decode(col1, 'COT' , col_val) col5
     42                 , t.col2 col_2
     43                 , row_number() over(partition by col2, col1 order by 1) rno
     44              from t
     45         )
     46   group
     47      by col_2, rno
     48   order
     49      by col_2;
    
    MAX(C MAX(C MAX(C MAX(C MAX(C
    ----- ----- ----- ----- -----
    Code1 L2    SSS
    L1
                ABC
                      Code2
                            BBV
                            QQQ
                            FFF
    
    7 rows selected.
    
    SQL>
    
  • The value of name of column

    Hi gurus

    I'm stuck on 1 Scenario and need your help. I have the following table:

    Create table

    drop table age_rate;

    CREATE TABLE age_rate
    (
    age_0_4 number 4,
    age_5_20 number 4,
    age_21_34 number 4,
    age_35_44 number 4
    );

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

    Insertion

    INSERT INTO age_rate

    SELECT 45, 50, 60, 90 double UNION ALL

    SELECT 45, 50, 60, 88 OF double UNION ALL

    SELECT the 40, 50, 60, 90 double UNION ALL

    SELECT 5, 50, 60 and 88 DOUBLE;

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

    Query on table

    SELECT * from age_rate;

    The query result

    age_0_4 age_5_20 age_21_34 age_35_44

    45                          50                     60                     90

    45                          50                     60                     88

    40                          50                     60                     90

    5                            50                     60                     88

    Power required

    Rate Min_age Max_age

    -The lower is age band 0_4

    45            0           4

    45            0           4

    40            0           4

    5              0           4

    -The lower is age band 5_20

    50            5           20

    50            5           20

    50            5           20

    50            5           20

    -The lower is age band 21_34

    60 21 34

    60 21 34

    60 21 34

    60 21 34

    -The lower is age band 35_44

    90 35 44

    88 35 44

    90 35 44

    88 35 44

    Rules

    -I have all the data in the rows each column online create separate lines and add 2 columns automatically Min_age and Max_age and insert the value on these columns based on the name of the column for example if the column name as age_0_4 then insert 0 in min_age and 4 in max_age means values for Min_age and Max_age extracted from the base of the column name. I don't know if it's possible or not, but I appreciate if someone can give me the solution for this problem... Do you like answers. Thank you


    Hello

    I'm not 100% sure what you want.  Do you want 16 production lines at a time, which is 4 lines of output for each line that is actually in the table?

    This looks like a job for the UNPIVOT operator:

    SELECTION rate

    min_age

    Case min_age

    WHEN 0 THEN 4

    WHEN 5 THEN 20

    WHEN 21 AND 34

    WHEN 35 THEN 44

    END AS max_age

    Of age_rate

    UNPIVOT (rate

    FOR min_age IN (age_0_4 0)

    age_5_20 AS 5

    age_21_34 AS 21

    age_35_44 AS 35

    )

    )

    ORDER BY min_age

    ;

  • Web Forms: Deleting line based on the value of a specific column

    Hello

    I have an online form in which I want to apply delete missing on the ranks, but only on the value of the first column. So, if the first column is #missing I want the deleted row, even if the columns are given in it.

    Is it possible to do this?

    I'm on ver 11.1.2.2 Hyperion Planning

    Shehzad

    Published by: shehzad k on January 24, 2013 11:51

    Unfortunately, no. There is no way to add the delete line based SOLELY on the existence of a value in the first column. It would be nice to see some of the more advanced features "conditional delete", we en flies over to the planning of the entry forms.

    You can do the "clumsy" things with data validations where you gray - out ranks in view of the existence of a value in a particular cell, however while this might SUGGEST that the user should not enter data in a particular line, it would not PREVENT to do so.

    We have seen many improvements in form lately with the introduction of data validations. I hope the momentum continues.

    -Jake

  • Add up the values from two numeric columns on RTF model

    Hello

    I'm trying to add up the values of the numeric column 2.

    I tried..? column_1 and column_2? > but it's not as simple as that obviously I get an error when you try to do

    I tried..? sum (current - group () / column_1) + sum (current - group () / column_2)? >, but who does no more work that it also returns an error


    Any ideas how to add two numeric columns in RTF model?

    for 2 + 3

     
    
  • Need help with Javascript to get the value of standard report column

    Hi all

    Apex 3.1 version

    I have a query SQL (editable report) region where I need to do validations using a process of OnDemand and javascript. For this posting, I need to use the serial number and id of this same report line item. The function is called when the serial number is changed. I can get the serial number easily because it is a text field, however, the item id is a standard report column (which actually a text field or hidden gives me a checksum error, long story). How can I get the value of the standard report column to set the value of an element of the Application to use in my process of application as well as the serial number? Here is my code below.
    <script>
    
    function f_ValidateSerial(pThis)
    {
        
      // The row in the table
    
      var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
    
        //alert('Row is '+vRow);
    
    
      // Display the serial number
        //alert('The Serial Number is '+html_GetElement('f21_'+vRow).value);
    
      
     var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=ValidateSerial',0);
     get.add('F101_SERIAL_NUMBER',html_GetElement('f21_'+vRow).value);
     get.add('F101_INVENTORY_ITEM_ID',+html_GetElement(?????+vRow).value);   // Here's where I need to get the item id to set application item!!
     
     gReturn = get.get();
     
    if (gReturn)
        { 
          alert(gReturn);
        }
     
      if(gReturn)
        { 
          html_GetElement('f21_'+vRow).value = '';
        }
               
    }
    </script>

    Hello

    Ok

    Item ID is standard report column.
    If you enter this Expression HTML column

    #ITEM_ID#
    

    I guess that the substitution of column item Id is #ITEM_ID #.

    Now, you have hidden input form that is not submitted.
    Then in JavaScript

    get.add('F101_INVENTORY_ITEM_ID',+html_GetElement('item_id_'+Number(vRow)).value);
    

    Kind regards
    Jari

  • I can't change the values of advanced type (exponent and index)

    When I try to use index and exponent my text disappears. First of all, I think that it is related to my font, but when I open Type preferences / advanced, I saw that the values of size and location of the exhibitor and index are nil. Whenever I changed it and they zero tricks once again. I want to reset these values and set as default on a permanent basis.

    Thank you for the answers.

    I use my native language (Turkish) InDesing because Adobe offers student only in the native language edition.

    (I hope that they will also offer English version. Because it's the translation is terrible).

    Default values for new text are defined by making changes with no selected text (and no active text cursor). If there is an open document, the default will apply only in the current document, any document open will apply to all new files. No change in the defaults will change existing text, or the default value for any existing document that is not active at the time the change is made, so all existing files need manual corrections.

  • Setting the value of XML in Java script tag

    Hello

    I'm trying to set a value of XML tag in the initialize to a text field event... The code works correctly in FormCalc but I needed it to work in java script.

    FormCalc:

    $record.prospectApplication.typeName = "namedInsured";

    Java Script:

    xfa.record.prospectApplication.typeName = "namedInsured";

    The JavaScript above does not work. Can help any one on this?

    Thank you

    Srini

    Hi Srini,

    In JavaScript you do get all properties by default if you need to say;

    xfa.record.prospectApplication.typeName.value = "namedInsured";

    Who is assign the value to the property "value" not the dataValue object.

Maybe you are looking for