XMLTable performance vs TABLE (XMLSequence ())

Hello world

I encountered a problem which I hope I can find help with.

He has a task to analyze a large XML text (~ 15 MB) and update a table based on it. So I created a procedure that takes a parameter of XMLType and does the job. Pretty simple. However, the thing is that if I use XMLTable, which is the preferred method to parse the XML, it runs for hours. Once I replace XMLTable with the method TABLE (XMLSequence ()), the procedure ends in less than two minutes on the same machine. Seems very strange to me.

Any ideas what could be the cause of such a poor performance from XMLTable?
Oracle version is 11.2.0.2.0

H1. The table structure
create table Points (
  member_id int not null,
  point_id int,
  country_numeric character(3),
  place national character varying(50),
  name national character varying(255),
  currencies national character varying(255),
  address national character varying(255),
  contact national character varying(40),
  contact_phone national character varying(40),
  details national character varying(255),
  enabled_date date,
  works national character varying(255),
  active character default 1 check (active in (0, 1)) not null,
  unique (member_id, point_id)
);
H1. XMLTable method
runs for several hours, if the input parameter is long of ~ 15 MB
  create procedure update_Points (
    p_Points in xmltype
  ) as
  begin
    insert into Points (member_id, point_id, country_numeric, place, name, currencies, address, contact, contact_phone, details, enabled_date, works)
    select
      ap.member_id,
      ap.point_id,
      ap.country_numeric,
      ap.place,
      ap.name,
      ap.currencies,
      ap.address,
      ap.contact,
      ap.contact_phone,
      ap.details,
      to_date(ap.enabled_date, 'DD.MM.YYYY'),
      ap.works
    from
      xmltable('for $Point in /document/directory/reply[@type=''Points'']/data/row return element Point { attribute member_id { $Point/column[@col=''1'']/@value }, attribute point_id { $Point/column[@col=''2'']/@value }, attribute country_numeric { $Point/column[@col=''3'']/@value }, attribute place { $Point/column[@col=''4'']/@value }, attribute name { $Point/column[@col=''5'']/@value }, attribute currencies { $Point/column[@col=''6'']/@value }, attribute address { $Point/column[@col=''7'']/@value }, attribute contact { $Point/column[@col=''8'']/@value }, attribute contact_phone { $Point/column[@col=''9'']/@value }, attribute details { $Point/column[@col=''10'']/@value }, attribute enabled_date { $Point/column[@col=''11'']/@value }, attribute works { $Point/column[@col=''12'']/@value } }'
        passing p_Points
        columns
          member_id int path '@member_id',
          point_id int path '@point_id',
          country_numeric character(3) path '@country_numeric',
          place national character varying(50) path '@place',
          name national character varying(255) path '@name',
          currencies national character varying(255) path '@currencies',
          address national character varying(255) path '@address',
          contact national character varying(40) path '@contact',
          contact_phone national character varying(40) path '@contact_phone',
          details national character varying(255) path '@details',
          enabled_date character(10) path '@enabled_date',
          works national character varying(255) path '@works') ap;
  end;
H1. Method table (XMLSequence ())
2 minutes with the same input parameter
  create procedure update_Points (
    p_Points in xmltype
  ) as
  begin
    insert into Points (member_id, point_id, country_numeric, place, name, currencies, address, contact, contact_phone, details, enabled_date, works)
    select
      value(x).extract('row/column[@col=''1'']/@value').getStringVal() member_id,
      value(x).extract('row/column[@col=''2'']/@value').getStringVal() point_id,
      value(x).extract('row/column[@col=''3'']/@value').getStringVal() country_numeric,
      value(x).extract('row/column[@col=''4'']/@value').getStringVal() place,
      extractValue(value(x), '/row/column[@col=''5'']/@value') name,
      value(x).extract('row/column[@col=''6'']/@value').getStringVal() currencies,
      value(x).extract('row/column[@col=''7'']/@value').getStringVal() address,
      value(x).extract('row/column[@col=''8'']/@value').getStringVal() contact,
      value(x).extract('row/column[@col=''9'']/@value').getStringVal() contact_phone,
      value(x).extract('row/column[@col=''10'']/@value').getStringVal() details,
      to_date(value(x).extract('row/column[@col=''11'']/@value').getStringVal(), 'DD.MM.YYYY') enabled_date,
      value(x).extract('row/column[@col=''12'']/@value').getStringVal() works
    from
      table(xmlsequence(extract(p_Points, '/document/directory/reply[@type=''Points'']/data/row'))) x;
  end;
H1. Small example of XML
<?xml version="1.0"?>
<document>
  <directory>
    <reply type="Points">
      <data>
        <row>
          <column col="1" value="0"></column>
          <column col="2" value=""></column>
          <column col="3" value="643"></column>
          <column col="4" value="Something"></column>
          <column col="5" value="&quot;Sample&quot;"></column>
          <column col="6" value=""></column>
          <column col="7" value="Blah"></column>
          <column col="8" value="Bar"></column>
          <column col="9" value="0123456789"></column>
          <column col="10" value=""></column>
          <column col="11" value="01.01.2010"></column>
          <column col="12" value=""></column>
        </row>
      </data>
    </reply>
  </directory>
</document>
Published by: 999663 on April 15, 2013 13:21

Because you have them different tasks. With the XML Table, you create a game via the return of intermediate results. Why not use the same approach to Table (XMLSequence ()) as in

    select
      ap.member_id,
      ap.point_id,
      ap.country_numeric,
      ap.place,
      ap.name,
      ap.currencies,
      ap.address,
      ap.contact,
      ap.contact_phone,
      ap.details,
      to_date(ap.enabled_date, 'DD.MM.YYYY'),
      ap.works
    from
      xmltable('/document/directory/reply[@type=''Points'']/data/row'
        passing p_Points
        columns
          member_id int path 'column[@col="1"]/@value',
          point_id int path 'column[@col="2"]/@value',
          country_numeric character(3) path 'column[@col="3"]/@value',
          place national character varying(50) path 'column[@col="4"]/@value',
          name national character varying(255) path 'column[@col="5"]/@value',
          currencies national character varying(255) path 'column[@col="6"]/@value',
          address national character varying(255) path 'column[@col="7"]/@value',
          contact national character varying(40) path 'column[@col="8"]/@value',
          contact_phone national character varying(40) path 'column[@col="9"]/@value',
          details national character varying(255) path 'column[@col="10"]/@value',
          enabled_date character(10) path 'column[@col="11"]/@value',
          works national character varying(255) path 'column[@col="12"]/@value') ap;

I hope it works now as fast as the old method, but you will need to provide the statistics on that. I'm interested to see the moment of execution.

Now if you want it to run faster, then

CREATE TABLE xml_hold (xml_col xmltype);  -- can be a global temporary table if you desire

and in your code

INSERT INTO xml_hold VALUES (p_points);

then change select it above to

    from xml_hold xh
      xmltable('/document/directory/reply[@type=''Points'']/data/row'
        passing xh.xml_col

This works because the default storage for XMLType columns in 11.2.0.2 was replaced by SECUREFILE XML BINARY. When you store XML in this column, Oracle preprocesses the XML file and stores the data in a binary format that is more effective to deal with. You can read about that in the Oracle documentation if you wish. Even with the charge to convert the XML into an internal format, the whole processing time should be faster given the application can now run much more efficiently.

Tags: Oracle Development

Similar Questions

  • Order items TABLE (XMLSEQUENCE (Extract (...)))

    Hello

    I inherited a piece of SQL, extract information from an XMLTYPE column and I have a problem with the order of the returned items.

    My XML looks like this:

    < recommendation > < row >... < / line > < row >... < / Line > etc. < / recommendation >

    This is a comment and is divided into several lines (a limitation of the source system).

    I want to read the contents of each line and save it in a VARCHAR2 field but I want to keep the original order of the < row > elements to have a message with a sense in the end, beside the text I want to store a "Line number" column

    To make this work, I got something like this:

    SELECT

    a.ID,

    Extract (value (Rec), 'Line') online.

    ROW_NUMBER() over (PARTITION BY a.id ORDER BY null) as line_number

    Loads of table_with_the_id_to_process,

    table_with_my_XML has,

    REC TABLE (XMLSEQUENCE (EXTRACT (a.xmltext, ' / / recommendation/Line ')))

    WHERE a.id = loads.id

    It worked fine with 2-3 rows during the tests, but when running on real data (250-300 lines with XML fields) "line_number" become a bit at random: always start at 1 and go up until the number of element < row >, the order is as randomly, so my comments doesn't have a logical sense if I retrieve ordered them to "line_number.

    Any idea on how to get the <>the position of number or something else to calculate my column "line_number?

    Maybe I missed in the doc and Google simply because using bad language of research, so I'm open to any suggestion or idea.

    Thank you

    Gianni,

    What is your version of the database?

    The construction of the TABLE/XMLSequence has been deprecated in 11.2 for the function XMLTABLE.

    XMLTABLE is available from version 10.2 and has a clause for ORDINALITE to generate the sequence of required integer.

    You can also rebuild the entire message in a single VARCHAR2 or CLOB (depending on the size) and get rid of these line numbers.

  • XDB. XMLIndex problem and table (XMLSEQUENCE (EXTRACT (xmltype, path))

    Hello
    I have a database of Oracle 11 g Release 11.1.0.6.0 - 64 bit Production With the Real Application Clusters option.

    I feel something strange with an XMLType column.
    I have a table configurator.t_vehicle_configuration (id_vehicle x_configuration NUMBER, XMLType).
    x_configuration is unstructured.

    I created an index on the field of xml in this way:

    CREATE INDEX idx_vehicle_configuration ON configurator.t_vehicle_configuration (x_configuration) INDEXTYPE IS XDB. XMLIndex;

    Then I have a package implementing a function that count nodes in the xml field and its return values

    This does not (return 0 instead of 1):
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    This mode of operation (return 1):
        str_ := '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen';
    
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration,str_))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    As this mode of operation:
        SELECT /*+ NO_XMLINDEX_REWRITE */ count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    And also this way it works:
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="228"]/user[@id="49"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    I sailed a bit on the internet but I have found no help for my problem...
    I guess that's something concerning the substitution on the fly of the variables, which does not work with an index.
    Do you have any suggestions?
    Is there a way that will prevent the rewriting of all the functions?

    Thanks in advance

    First

    On 11.1.0.6.0 Please do not use table (xmlsequence (extract ())) Please use the SQL/XML standard XMLTAble operator...

    SELECT COUNT(*)
       INTO count_
      FROM configurator.v_vehicle_configuration vc,
               XMLTABLE
              (
                  '$XML/vehicleconf/GeoFence/spaceTarget[@id=$ID_SPACE_TARGET]/user[@id=$ID_USER]/alarmwhen'
                  passing vc.x_configuration as "XML",  in_id_space_target as "ID_SPACE_TARGET",  in_id_user as "ID_USER"
               )
         WHERE vc.id_vehicle = in_id_vehicle;
    
        RETURN count_;
    

    2. never generate XPATH strings dynamically (Note XMLTABLE simply will not allow it). It is almost impossible to optimize since in the case escalated, the query may be a function of the processing line, and it leaves the vulnerable application WHO the problems of injection. Earlier versions of XML DB supported the use of string concatenation technique to provide the value of predicate as a method of implementation of the bind variable, but from what I remember, this is only implemented and tested for storage relatiion object. Even when workng with storage relational object this technique should not be used in the development of new code n a 10.2.x post database. As far as I know this was not implemented for binary XML / XML INdex since the implementations of XMLQUERY, XMLTable and XMLEXists provided a much more robust implementation and standardized to link the underlying values at query runtime

    If you do not know the XPATH expression until run time please build the complete SQL statement dynamically and run it via EXECUTE IMMEDIATE or DBMS_SQL, then pay attention to injection vunerabilities in your application.

    The fact that you get different results seems to be the result of the previous method of binding of predicates works do not correctly with the XML Index. If the solution I gave above does not work, please fill out a bug and that we can continue the investigation

    Published by: mdrake on February 25, 2011 17:32

  • Tips on optimizing the performance of table.

    Hello

    I read several article on optimizing the performance for the table. Finally, I settle on a strategy to implement, but I have a few questions.

    Let's say we want to display a wide range of data in a table. The number of lines displayed on the screen is n = 25.

    For each VO displayed in table form: Open model project->->->-> Data Model Instances to View object Data Model Module of Application -> select your view object-> press the modify... button-> Tuning

    • For best performance Oracle ADF Performance Tuning Documentation indicates that in lots of field must be set to n + 3
    • The scope of the queryoptimizer indicator should be the value + 3, so if n = 25, FIRST_ROWS_28 FIRST_ROWS_n
    • By default, access is set to Scrollable, which is OK as long as you aren't iteration in a large data set, but if you are, then you must change the Access Mode to the Range Paging
    • Set the size of the beach to n + 3

    Q1: What is the reasonable maximum for a set size? Client wants to display huge table as 200 lines that is not really usable, but it's what they want. I was wondering if the definition of the size of the beach at 203 is a reasonable value, or if it is too high.

    Q2: I have really not understand the purpose of the indicator of QueryOptimizer even after reading the documentation. Is it okay to put it at FIRST_ROWS_203 if your batch size is 203?

    Thank you

    JDev 11.1.2.4

    What version of jdev we are talking about?

    Is the table in paging mode (+ 11.1.1.7)?

    Q1 Yes), the tip is still standing, then set-203. The reason is that the table will display 200 lines that you need to load them in any case. In this case, it is best to load them into a round trip. a smaller rangesize then the number of visible rows in the table means more then 1 trip on the server and the db.

    Q2) the query optimizer indicator is just passed to the db which then decides to use it or not. The indicator shows the db to deliver the first n lines of results as soon as possible. If you have large result sets the db can provide the result set when it comes always collection more data FRO the game results in the background. This will display the fastest page to the user.

    Timo

  • Insertion of XMLTABLE to RELATIONAL table

    Hello

    I have a Realational table


    CREATE TABLE VALU_RSLT)
    VALU_RSLT_ID NUMBER OF NON-NULL,
    NUMBER OF FRD_RQST_INFO_ID
    NUMBER OF CERT_NBR (12: 0),
    VALUATIONMETHODTYPE VARCHAR2 (4000).
    VALUATIONMODEL VARCHAR2 (4000).
    EARNED NUMBER (20: 5).
    NUMBER OF VALUATIONLOW (20: 5),
    NUMBER OF VALUATIONHIGH (20: 5),
    NUMBER OF CONFIDENCESCORE
    CONFIDENCEDESC VARCHAR2 (255),
    CRT_BY_USR_ID VARCHAR2 (255),
    CRT_TMST TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    LAST_UPD_BY_USR_ID VARCHAR2 (255),
    LAST_UPD_TMST TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );



    VALU_RSLT_ID - is a sequence object.


    Select tx. FRD_RQST_INFO_ID, CERT_NBR, temp.*
    OF FRD_XML_TEST1 tx.
    XMLTABLE ('/ DRIVEResponse/loan/assessments/ValuationResult ')
    TX OF PASSAGE. RSP_XML
    PATH of COLUMNS 'ValuationMethodType' VARCHAR2 (4000) "@ValuationMethodType."
    Path of 'ValuationModel' VARCHAR2 (4000) "@ValuationModel."
    "Assessment" PATH of NUMBER (20.5) "@Valuation."
    Path of "ValuationLow" NUMBER (20.5) "@ValuationLow."
    Path of "ValuationHigh" NUMBER (20.5) "@ValuationHigh."
    PATH of NUMBER "ConfidenceScore" "@ConfidenceScore"
    PATH of VARCHAR2 (255) 'ConfidenceDesc' '@ConfidenceDesc '.
    ) in the temp


    Is a very good job.


    What I try to achieve is to insert the data from the XML for this relational Table (VALU_RSLT) and also to increment the Sequence (VALU_RSLT_ID) and others
    check the fields in the table. (CRT_BY_USR_ID, CRT_TMST, LAST_UPD_BY_USR_ID, LAST_UPD_TMST).

    How can I do this?


    I tried something like this

    INSERT into VALU_RSLT (VALU_RSLT_ID, FRD_RQST_INFO_ID, CERT_NBR, VALUATIONMETHODTYPE, VALUATIONMODEL, EARNED,
    VALUATIONLOW, VALUATIONHIGH, CONFIDENCESCORE, CONFIDENCEDESC, CRT_BY_USR_ID, CRT_TMST, LAST_UPD_BY_USR_ID, LAST_UPD_TMST)
    VALUES (VALU_RSLT_ID_SEQ1.nextval (), select tx. FRD_RQST_INFO_ID, CERT_NBR, temp.*
    OF FRD_XML_TEST1 tx.
    XMLTABLE ('/ DRIVEResponse/loan/assessments/ValuationResult ')
    TX OF PASSAGE. RSP_XML
    PATH of COLUMNS 'ValuationMethodType' VARCHAR2 (4000) "@ValuationMethodType."
    Path of 'ValuationModel' VARCHAR2 (4000) "@ValuationModel."
    "Assessment" PATH of NUMBER (20.5) "@Valuation."
    Path of "ValuationLow" NUMBER (20.5) "@ValuationLow."
    Path of "ValuationHigh" NUMBER (20.5) "@ValuationHigh."
    PATH of NUMBER "ConfidenceScore" "@ConfidenceScore"
    PATH of VARCHAR2 (255) 'ConfidenceDesc' '@ConfidenceDesc '.
    (), Temp, NULL, NULL, NULL, NULL);



    gave me the following error message

    Error in the command line: 3 column: 35
    Error report:
    SQL error: ORA-00936: lack of expression
    00936 00000 - "missing expression.
    * Cause:
    * Action:


    How can I do this insert work?

    You mix styles of syntax INSERT. VALUES is for a single line. You want something like

    INSERT into VALU_RSLT(VALU_RSLT_ID, FRD_RQST_INFO_ID, CERT_NBR, VALUATIONMETHODTYPE, VALUATIONMODEL, VALU,
    VALUATIONLOW, VALUATIONHIGH, CONFIDENCESCORE, CONFIDENCEDESC, CRT_BY_USR_ID, CRT_TMST, LAST_UPD_BY_USR_ID, LAST_UPD_TMST)
    select VALU_RSLT_ID_SEQ1.nextval(),
           tx.FRD_RQST_INFO_ID,CERT_NBR,temp.*,
           NULL,NULL,NULL,NULL
    FROM FRD_XML_TEST1 tx,
         XMLTABLE('/DRIVEResponse/Loan/Valuations/ValuationResult'
                  PASSING TX.RSP_XML
                  COLUMNS
                  "ValuationMethodType" VARCHAR2(4000) PATH '@ValuationMethodType',
                  "ValuationModel" VARCHAR2(4000) PATH '@ValuationModel',
                  "Valuation" NUMBER(20,5) PATH '@Valuation',
                  "ValuationLow" NUMBER(20,5) PATH '@ValuationLow',
                  "ValuationHigh" NUMBER(20,5) PATH '@ValuationHigh',
                  "ConfidenceScore" NUMBER PATH '@ConfidenceScore',
                  "ConfidenceDesc" VARCHAR2(255) PATH '@ConfidenceDesc');
    
  • Commit performance on table with Fast Refresh MV

    Hello world

    Try to wrap your head around fast refresh performance and why I see (what I consider) high disk numbers / query associated with the update of the MV_LOG in a TKPROF.

    The installation program.
    (Oracle 10.2.0.4.0)

    Database table:
    SQL> desc action;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     PK_ACTION_ID                              NOT NULL NUMBER(10)
     CATEGORY                                           VARCHAR2(20)
     INT_DESCRIPTION                                    VARCHAR2(4000)
     EXT_DESCRIPTION                                    VARCHAR2(4000)
     ACTION_TITLE                              NOT NULL VARCHAR2(400)
     CALL_DURATION                                      VARCHAR2(6)
     DATE_OPENED                               NOT NULL DATE
     CONTRACT                                           VARCHAR2(100)
     SOFTWARE_SUMMARY                                   VARCHAR2(2000)
     MACHINE_NAME                                       VARCHAR2(25)
     BILLING_STATUS                                     VARCHAR2(15)
     ACTION_NUMBER                                      NUMBER(3)
     THIRD_PARTY_NAME                                   VARCHAR2(25)
     MAILED_TO                                          VARCHAR2(400)
     FK_CONTACT_ID                                      NUMBER(10)
     FK_EMPLOYEE_ID                            NOT NULL NUMBER(10)
     FK_ISSUE_ID                               NOT NULL NUMBER(10)
     STATUS                                             VARCHAR2(80)
     PRIORITY                                           NUMBER(1)
     EMAILED_CUSTOMER                                   TIMESTAMP(6) WITH LOCAL TIME
                                                         ZONE
    
    
    SQL> select count(*) from action;
    
      COUNT(*)
    ----------
       1388780
    MV was created
    create materialized view log on action with sequence, rowid
    (pk_action_id, fk_issue_id, date_opened) 
    including new values;
    
    -- Create materialized view
    create materialized view issue_open_mv
    build immediate
    refresh fast on commit
    enable query rewrite as 
    select  fk_issue_id issue_id,
         count(*) cnt,
         min(date_opened) issue_open,
         max(date_opened) last_action_date,
         min(pk_action_id) first_action_id,
         max(pk_action_id) last_action_id,
         count(pk_action_id) num_actions
    from    action
    group by fk_issue_id;
    
    exec dbms_stats.gather_table_stats('tg','issue_open_mv')
    
    SQL> select table_name, last_analyzed from dba_tables where table_name = 'ISSUE_OPEN_MV';
    
    TABLE_NAME                     LAST_ANAL
    ------------------------------ ---------
    ISSUE_OPEN_MV                  15-NOV-10
    
    *note: table was created a couple of days ago *
    
    SQL> exec dbms_mview.explain_mview('TG.ISSUE_OPEN_MV');
    
    CAPABILITY_NAME                P REL_TEXT MSGTXT
    ------------------------------ - -------- ------------------------------------------------------------
    PCT                            N
    REFRESH_COMPLETE               Y
    REFRESH_FAST                   Y
    REWRITE                        Y
    PCT_TABLE                      N ACTION   relation is not a partitioned table
    REFRESH_FAST_AFTER_INSERT      Y
    REFRESH_FAST_AFTER_ANY_DML     Y
    REFRESH_FAST_PCT               N          PCT is not possible on any of the detail tables in the mater
    REWRITE_FULL_TEXT_MATCH        Y
    REWRITE_PARTIAL_TEXT_MATCH     Y
    REWRITE_GENERAL                Y
    REWRITE_PCT                    N          general rewrite is not possible or PCT is not possible on an
    PCT_TABLE_REWRITE              N ACTION   relation is not a partitioned table
    
    13 rows selected.
    Fast refresh works fine. And the newspaper is kept small enough.
    SQL> select count(*) from mlog$_action;
    
      COUNT(*)
    ----------
             0
    When I update a row in the base table:
    var in_action_id number;
    
    exec :in_action_id := 398385;
    
    UPDATE action
    SET emailed_customer = SYSTIMESTAMP
    WHERE pk_action_id = :in_action_id
    AND DECODE(emailed_customer, NULL, 0, 1) = 0
    /
    
    commit;
    What follows, I get via tkprof.
    ********************************************************************************
    
    INSERT /*+ IDX(0) */ INTO "TG"."MLOG$_ACTION" (dmltype$$,old_new$$,snaptime$$,
      change_vector$$,sequence$$,m_row$$,"PK_ACTION_ID","DATE_OPENED",
      "FK_ISSUE_ID")
    VALUES
     (:d,:o,to_date('4000-01-01:00:00:00','YYYY-MM-DD:HH24:MI:SS'),:c,
      sys.cdc_rsid_seq$.nextval,:m,:1,:2,:3)
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.01          0          0          0           0
    Execute      2      0.00       0.03          4          4          4           2
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        3      0.00       0.04          4          4          4           2
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          2  SEQUENCE  CDC_RSID_SEQ$ (cr=0 pr=0 pw=0 time=28 us)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                         4        0.01          0.01
    ********************************************************************************
    
    ********************************************************************************
    
    update "TG"."MLOG$_ACTION" set snaptime$$ = :1
    where
     snaptime$$ > to_date('2100-01-01:00:00:00','YYYY-MM-DD:HH24:MI:SS')
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.01          0          0          0           0
    Execute      1      0.94       5.36      55996      56012          1           2
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        2      0.94       5.38      55996      56012          1           2
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          0  UPDATE  MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=5364554 us)
          2   TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=46756 us)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file scattered read                       3529        0.02          4.91
    ********************************************************************************
    
    select dmltype$$, max(snaptime$$)
    from
     "TG"."MLOG$_ACTION"  where snaptime$$ <= :1  group by dmltype$$
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.70       0.68      55996      56012          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.70       0.68      55996      56012          0           1
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          1  SORT GROUP BY (cr=56012 pr=55996 pw=0 time=685671 us)
          2   TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=1851 us)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file scattered read                       3529        0.00          0.38
    ********************************************************************************
    
    delete from "TG"."MLOG$_ACTION"
    where
     snaptime$$ <= :1
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.71       0.70      55946      56012          3           2
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        2      0.71       0.70      55946      56012          3           2
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          0  DELETE  MLOG$_ACTION (cr=56012 pr=55946 pw=0 time=702813 us)
          2   TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55946 pw=0 time=1814 us)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file scattered read                       3530        0.00          0.39
      db file sequential read                        33        0.00          0.00
    ********************************************************************************
    Could someone explain why the the SELECT/UPDATE/DELETE on MLOG$ _ACTION if 'expensive' when it should be only 2 rows (the old value and the new value) in this newspaper after an update? I could do to improve the performance of the update?

    Let me know if you need more info... would be happy to provide.

    My guess would be that you were once a very large transaction that inserted a large number of rows in this table. So the table segment is big enough now and the high watermark is average at the end of this segment, causing a full scan table to analyze a large number of empty blocks and retrieve the two lines.

    You can issue a truncation on this table of $ MLOG: which would free up the empty blocks and brings back the high-watermark in the first block.

  • Performance overview tables appears no not after the upgrade...

    After the upgrade to vcenter, the overview of the performance does not appear?

    see this KB

    http://KB.VMware.com/kb/1008330

  • Update of the data in the Table using XMLTYPE DATA

    I did insertions using XMLTYPE data but have never done it and update. Can someone give me some advice?

    PROCEDURE ADD_LABORDER_CODES)

    IN_ORDERCODESXML IN CLOB DEFAULT NULL,

    Number of OUT OUT_AFFECTEDROWS

    )

    AS

    X SYS. XMLTYPE;

    BEGIN

    X: = SYS. XMLTYPE. CREATEXML (IN_ORDERCODESXML);

    INSERT INTO MAINT_LABORD_CODES)

    INSERT INTO MAINT_LABORD_CODES)

    LABORD_CODE_ID,

    COMPENDIUM_ID,

    ORDER_CODE,

    ORDER_DESC,

    ACTIVE,

    TIMESTAMP,

    MODIFIED_BY)

    SELECT MLOCDS_SEQ. NEXTVAL,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/COMPENDIUM_ID') AS COMPENDIUM_ID,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/ORDER_CODE') AS ORDER_CODE,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/ORDER_DESC') AS ORDER_DESC,.

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/LOINC_CODE') AS LOINC_CODE,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/ACTIVE') AS ACTIVE.

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/TIMESTAMP') AS TIMESTAMP.

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/MODIFIED_BY') AS MODIFIED_BY

    TABLE (XMLSEQUENCE (EXTRACT(X,'/ORDERCODES/ORDERCODE'))) NMCO;

    OUT_AFFECTEDROWS: = NUMBER OF ROWS SQL %;

    EXCEPTION

    WHILE OTHERS THEN

    dbms_output.put_line (SQLERRM);

    RAISE_APPLICATION_ERROR (-20001, SQLERRM);

    END;

    Example of use of the FUSION-

    If the line exists in the target table (based on the COMPENDIUM_ID and ORDER_CODE values), the UPDATE is, if not to INSERT:

    declare
    
      in_ordercodesxml  clob :=
      '
      
        500
        696231
        ABO Group & Rh Type
        NULL
        12345
        Y
        2014-08-13
        1
      
    ';
    
    begin
    
      merge into maint_labord_codes t
      using (
        select compendium_id
             , order_code
             , order_desc
             , loinc_code
             , active
             , timestamp
             , modified_by
        from xmltable('/ORDERCODES/ORDERCODE'
               passing xmltype(in_ordercodesxml)
               columns COMPENDIUM_ID    number(10)    path 'COMPENDIUM_ID'
                     , ORDER_CODE       varchar2(50)  path 'ORDER_CODE'
                     , ORDER_DESC       varchar2(250) path 'ORDER_DESC'
                     , LOINC_CODE       varchar2(10)  path 'LOINC_CODE'
                     , ACTIVE           varchar2(1)   path 'ACTIVE'
                     , TIMESTAMP        date          path 'TIMESTAMP'
                     , MODIFIED_BY      number(10)    path 'MODIFIED_BY'
             )
      ) x
      on (     t.compendium_id = x.compendium_id
           and t.order_code = x.order_code )
      when matched then update
        set t.order_desc = x.order_desc
          , t.loinc_code = x.loinc_code
          , t.active     = x.active
          , t.timestamp  = x.timestamp
          , t.modified_by = x.modified_by
      when not matched then insert
      (
        labord_code_id
      , compendium_id
      , order_code
      , order_desc
      , loinc_code
      , active
      , timestamp
      , modified_by
      )
      values (
        mlocds_seq.nextval
      , x.compendium_id
      , x.order_code
      , x.order_desc
      , x.loinc_code
      , x.active
      , x.timestamp
      , x.modified_by
      );
    
    end;
    /
    

    Also note that I used XMLTABLE instead of TABLE/XMLSEQUENCE, which is much easier to use (and not deprecated in the latest versions).

    You have not precisely the date format in the TIMESTAMP element so I assumed a conform to W3C.

    If you have a problem with this part, return to a projection of VARCHAR2 and use TO_DATE with actual size.

  • XQuery - looking for alternatives to "ora: view»

    Instead of the following XQuery statement, what could be, alternatives for re-writing the declaration, through options such as:
    -xmltable
    -xsql
    -xpath
    -table (xmlsequence ())
    -etc.

    So, I'm looking for other statements and/or an alternative for ora: view

    Thanks for the effort

    Marco
    xquery
     let $auction := ora:view("XMLType_Table") return
     for $b in $auction/site/people/person[@id = "person0"] return $b/name/text()
    /
    Published by: Marco Gralike on October 19, 2008 15:48

    And here is a table (version xmlsequence

    select extractValue(value(e), 'name')
    from XTAB,
    TABLE(xmlsequence(extract(object_value,'site/people/person[@id = "person0"]/name'))) e;
    
  • XMLSEQUENCE or XMLTABLE

    I'm XML file I have loaded like a BLOB, then converted into a XML_TYPE and converted into a CLOB

    I use the following SQL code to extract the data

    the table is imp_xml_file and the column is xml_xml
    select  
    x.xml_xml.extract('aircraft/brochure/part/partNumber/text()').getstringval() as partno,
    x.xml_xml.extract('aircraft/brochure/part/NSCM/text()').getstringval() as NCSM, 
    x.xml_xml.extract('aircraft/brochure/part/LCN/text()').getstringval() as LCN,
    x.xml_xml.extract('aircraft/brochure/part/zone/text()').getstringval() as PZONE,
    from imp_xml_file x,table(xmlsequence(extract(xml_xml, '/aircraft/brochure/part'))) d
    where id = p_id
    
    there are 7 records in the XML file 
    
    if i use table(xmlsequence(extract(xml_xml, '/aircraft/brochure/part'))) d
    
    it returns 7 rows and each column but all data is concatenated for each field  
    
    if i use table(xmlsequence(extract(xml_xml, '/aircraft/brochure/'))) d
    it returns 1 with all the fileds concatenated 
    
    this is the data
    <?xml version="1.0" standalone="yes" ?> 
    - <aircraft>
      <buildNumber>BS059</buildNumber> 
    - <brochure>
      <dataSource>Centre Fuselage EPC Handover Brochure</dataSource> 
      <autoGeneratePhysicalPartRecords>YES</autoGeneratePhysicalPartRecords> 
      <importSerialNumbersInstallationDates>YES</importSerialNumbersInstallationDates> 
    - <part>
      <NSCM>98441</NSCM> 
      <partNumber>743900-1</partNumber> 
      <serialNumber>EFA0276</serialNumber> 
      <LCN>X291211</LCN> 
      <zone>267</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>05/09/2008 00:00:00:000</installationDate> 
      </part>
    - <part>
      <NSCM>98441</NSCM> 
      <partNumber>743900-2</partNumber> 
      <serialNumber>EFA0276</serialNumber> 
      <LCN>X291111</LCN> 
      <zone>257</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>05/09/2008 00:00:00:000</installationDate> 
      </part>
    - <part>
      <NSCM>98441</NSCM> 
      <partNumber>743900-3</partNumber> 
      <serialNumber>EFA0272</serialNumber> 
      <LCN>X291226</LCN> 
      <zone>267</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>12/08/2008 00:00:00:000</installationDate> 
      </part>
    - <part>
      <NSCM>98441</NSCM> 
      <partNumber>743900-4</partNumber> 
      <serialNumber>EFA0271</serialNumber> 
      <LCN>X291126</LCN> 
      <zone>257</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>11/08/2008 00:00:00:000</installationDate> 
      </part>
    - <part>
      <NSCM>98441</NSCM> 
      <partNumber>743900-5</partNumber> 
      <serialNumber>EFA-0265</serialNumber> 
      <LCN>X291227</LCN> 
      <zone>267</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>24/07/2008 00:00:00:000</installationDate> 
      </part>
    - <part>
      <NSCM>98441</NSCM> 
      <partNumber>743900-6</partNumber> 
      <serialNumber>EFA-0263</serialNumber> 
      <LCN>X291127</LCN> 
      <zone>257</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>21/07/2008 00:00:00:000</installationDate> 
      </part>
    - <part>
      <NSCM>D1227</NSCM> 
      <partNumber>743900-7</partNumber> 
      <serialNumber>08060258</serialNumber> 
      <LCN>X212301</LCN> 
      <zone>274</zone> 
      <logCardRequired>-</logCardRequired> 
      <installationDate>01/08/2008 00:00:00:000</installationDate> 
      </part>
     </brochure>
      </aircraft>
    
    This is how the data is returned
    
    PARTNO     NCSM     LCN     PZONE
    
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    743900-1743900-2743900-3743900-4743900-5743900-6743900-7     984419844198441984419844198441D1227     X291211X291111X291226X291126X291227X291127X212301     267257267257267257274
    Any help greatly appreciated, all the examples seem to cover only 1 card in the XMLTYPE and it works very well with 1 card!
    not with 1 > :-((

    Chris

    Published by: CJ Bell on November 29, 2011 11:23

    Published by: CJ Bell on November 29, 2011 11:24

    Hi Chris,

    That's what you want:

    select extractvalue(x.column_value, '/part/partNumber') as PARTNO,
           extractvalue(x.column_value, '/part/NSCM') as NCSM,
           extractvalue(x.column_value, '/part/LCN') as LCN,
           extractvalue(x.column_value, '/part/zone') as PZONE
    from imp_xml_file t
       , table(
           xmlsequence(
             extract(t.xml_xml, '/aircraft/brochure/part'))
         ) x
    where id = p_id
    ;
    

    What is your version of the database? (select * from version$ v)
    From 10.2, XMLTable can do the same and much more.

    I'm XML file I have loaded like a BLOB, then converted into a XML_TYPE and converted into a CLOB

    Once again, depending on your version, you can load your file directly into the table with an INSERT.

  • XMLSequence to XMLTable

    Hello!

    I need assistance with XMLTable instead of XMLSequence.

    It's the part of my XML.
             <emiDocAnt>
                <owner>11111111111111</owner>
                <idDocAnt>
                  <idDocAntPap>
                    <tpDoc>01</tpDoc>
                  </idDocAntPap>
                  <idDocAntPap>
                    <tpDoc>02</tpDoc>
                  </idDocAntPap>
                </idDocAnt>
                <idDocAnt>
                  <idDocAntPap>
                    <tpDoc>03</tpDoc>
                  </idDocAntPap>
                  <idDocAntPap>
                    <tpDoc>04</tpDoc>
                  </idDocAntPap>
                </idDocAnt>
              </emiDocAnt>
              <emiDocAnt>
                <owner>22222222222222</owner>
                <idDocAnt>
                  <idDocAntPap>
                    <tpDoc>05</tpDoc>
                  </idDocAntPap>
                  <idDocAntPap>
                    <tpDoc>06</tpDoc>
                  </idDocAntPap>
                </idDocAnt>
              </emiDocAnt>
    I have this statement that works very well, it returns under the data within the Group of idDocAntPap and its owner.
    SELECT EXTRACTVALUE(VALUE(vw),'/emiDocAnt/owner'),
           EXTRACTVALUE(VALUE(vw3), '/idDocAntPap/tpDoc')
      FROM tb_projCargaTMP,
      TABLE(XMLSequence(EXTRACT(XMLAutorizacao,'/emiDocAnt'))) vw,
      TABLE(XMLSequence(EXTRACT(vw.column_value,'//idDocAnt'))) vw2,
      TABLE(XMLSequence(EXTRACT(vw2.column_value,'//idDocAntPap'))) vw3;
    But I would use XMLTable instead of XMLSequence. The problem is: How can I get the value of "owner"?
    SELECT vw."owner",
           vw."tpDoc"
      FROM tb_projCargaTMP,
      XMLTABLE('/emiDocAnt/idDocAnt/idDocAntPap'
               PASSING tb_CargaTMP.XMLAutorizacao
               COLUMNS "owner" NUMBER(14)     PATH ???, <-- How can I get the owner value?
                       "tpDoc" NUMBER(2)      PATH '/idDocAntPap/tpDoc',
                       "serie" VARCHAR2(3)    PATH '/idDocAntPap/serie',
                       "subserie" VARCHAR2(2) PATH '/idDocAntPap/subser',
                       "nDoc" NUMBER(20)      PATH '/idDocAntPap/nDoc',
                       "dEmi" DATE            PATH '/idDocAntPap/dEmi'
               ) vw;
    Thank you!!!

    Based on a similar question to {message identifier: = 4093475}, you have two options, depending on whether you want to use XQuery or not within XMLTable.

    WITH tb_projCargaTMP AS
    (SELECT XMLTYPE('
                11111111111111
                
                  
                    01
                  
                  
                    02
                  
                
                
                  
                    03
                  
                  
                    04
                  
                
              
              
                22222222222222
                
                  
                    05
                  
                  
                    06
                  
                
              ') XMLAutorizacao -- added root node to make valid XML
       FROM dual)
    SELECT vw.owner, vw2.*
      FROM tb_projCargaTMP,
      XMLTable('/root/emiDocAnt'
               PASSING tb_projCargaTMP.XMLAutorizacao
               COLUMNS
               owner      NUMBER(14)  PATH 'owner',
               antPapXML  XMLTYPE     PATH 'idDocAnt/idDocAntPap') vw,
      XMLTABLE('/idDocAntPap'
               PASSING vw.antPapXML
               COLUMNS
               tpDoc NUMBER(2)      PATH 'tpDoc',
               serie VARCHAR2(3)    PATH 'serie',
               subserie VARCHAR2(2) PATH 'subser',
               nDoc NUMBER(20)      PATH 'nDoc',
               dEmi DATE            PATH 'dEmi'
               ) vw2; 
    

    and

    SELECT vw.*
      FROM tb_projCargaTMP,
      XMLTable('for $i in /root/emiDocAnt/idDocAnt/idDocAntPap
                  return element r{$i/../../owner,
                                   $i/tpDoc,
                                   $i/serie}'  -- continue on
               PASSING tb_projCargaTMP.XMLAutorizacao
               COLUMNS
               owner      NUMBER(14)  PATH 'owner',
               tpDoc NUMBER(2)        PATH 'tpDoc',
               serie VARCHAR2(3)      PATH 'serie',
               subserie VARCHAR2(2)   PATH 'subser',
               nDoc NUMBER(20)        PATH 'nDoc',
               dEmi DATE              PATH 'dEmi') vw;
    
  • Query XML Webservice response in the table.

    Sorry this is a re-post because I thought that this forum is no longer relevant.
    (orginal: XML response from the Query Web service in table. )

    Hello

    I have a request to consume the web service and the XML response and populating a table. The XML query is less. It works fine for small set of data (< 100), however if the XML has more records (Eg 3000 +, 5 + MB) the query takes about 6 + minutes to return all results.

    I understand the query XML is a slow process, but I was wondering if there is anyway I could improve performance?

    Database: 11 GR 2
    select extractvalue(value(R),'//ns0:id', fl_flight_profile_ws.namespace) id,
           extractvalue(value(R),'//ns0:callsign', fl_flight_profile_ws.namespace) callsign,
           extractvalue(value(R),'//ns0:registration', fl_flight_profile_ws.namespace) registration,
           -------------------------------------
           ------------------------------------- << A total of 48 columns >>
           -------------------------------------  
           extractvalue(value(R),'//ns0:aircraftType', fl_flight_profile_ws.namespace) aircraft_type
    from (SELECT response FROM plv.ws_log WHERE log_id = 338639) x,
       table(XMLSequence(extract(x.response,'//ns0:result/ns0:ptypcfptOut',fl_flight_profile_ws.namespace))) R
    Thanks for your time.

    Cheers, Glenn Ligon

    Hello

    I hope that I am doing things!

    You are doing things.
    The binary XML storage is the way to go in the latest versions.

    However, you use deprecated functions to process the XML content. You must use XMLTable now.

    As far as possible, do not use the descendants axis (/ /), always specify the full XPath expression.

    Here is an example based on your existing query. You will need to adjust the mappings from namespace and XPath expressions, but this is the idea:

    select x.*
    from ws_xml t
       , xmltable(
           xmlnamespaces(
             'some.namespace.uri' as "ns0"
           , default 'my.default.namespace'
           )
         , '/root_element/sub_root_element/ns0:result/ns0:ptypcfptOut'
           passing t.response
           columns
             id              varchar2(30) path 'ns0:id'
           , callsign        varchar2(30) path 'ns0:callsign'
           , registration    varchar2(30) path 'ns0:registration'
             ...
           , aircraft_type   varchar2(30) path 'ns0:aircraftType'
         ) x
    ;
    
  • Loading nested XML file to a table

    Hi I have the following XML code.

    -< protocols >
    -Protocol of <>
    < name > SampleAddition_Outer < / name >
    < revision > 0 < / revision >
    -< ProtocolSteps >
    -< ProtocolStep >
    < name > SampleAddition < / name >
    < EnumProtocolStep > SampleAddition < / EnumProtocolStep >
    SampleProbe < action > < / Action >
    -< ParameterList >
    < string > SampleDispVol < / string >
    < string > SampleOverAspVol < / string >
    < string > LeadAirGap < / string >
    < string > TrailAirGap < / string >
    < string > SPPumpAspSpeed < / string >
    < string > SPPumpDispSpeed < / string >
    < string > SPPumpDispHeight < / string >
    < / ParameterList >
    < IntAction > 0 < / IntAction >
    < IntProtocolStep > 0 < / IntProtocolStep >
    < SequenceName > EmptySequence < / SequenceName >
    < / ProtocolStep >
    < / ProtocolSteps >

    This XML file is repeated over and over again in the large file.
    This is a nested structure and I want to store in a table so that the columns as follows

    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is SampleDispVol
    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is SampleOverAspVol
    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is LeadAirGap
    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is TrailAirGap
    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is SPPumpAspSpeed
    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is SPPumpDispSpeed
    Nom_protocole = SampleAddition_Outer, review = 0, ProtocolStep_Name = SampleAddition, EnumProtocolStep = SampleAddition, SampleProbe = Action, ParameterList is SPPumpDispHeight

    I understand that this table would be very standard but its OK for me now.

    I use oracle 10g.

    I loaded the entire xml in the unique xmltype column and used the following query to retrieve it.

    Select extractvalue (value (x), ' / Protocol/Name ") Nom_protocole,.
    ExtractValue (value (x), ' / ProtocolSteps/protocol/name of the Protocol / ") protocolstep_name
    of gt_xmltype_tab1 gt, TABLE (XMLSequence (extract (gt.xmlfile1, ' / Protocols/Protocol/ProtocolSettings '))) x;


    But it shows only Nom_protocole in the output. There is no error in the execution, but the output is not good either.
    I use Oracle 10 g

    Could someone help out here?

    If I understand correctly, you have three levels unnest here, so you need three nested XMLSequence:

    SQL> create table tmp_xml of xmltype;
    
    Table created
    
    SQL>
    SQL> insert into tmp_xml values(
      2  xmltype(
      3  '
      4    
      5      SampleAddition_Outer
      6      0
      7      
      8        
      9          SampleAddition
     10          SampleAddition
     11          SampleProbe
     12          
     13            SampleDispVol
     14            SampleOverAspVol
     15            LeadAirGap
     16            TrailAirGap
     17            SPPumpAspSpeed
     18            SPPumpDispSpeed
     19            SPPumpDispHeight
     20          
     21          0
     22          0
     23          EmptySequence
     24        
     25      
     26    
     27  ')
     28  );
    
    1 row inserted
    
    SQL>
    SQL> select extractValue(value(x1), '/Protocol/Name') as Protocol_Name
      2       , extractValue(value(x1), '/Protocol/Revision') as Revision
      3       , extractValue(value(x2), '/ProtocolStep/Name') as ProtocolStep_Name
      4       , extractValue(value(x2), '/ProtocolStep/EnumProtocolStep') as EnumProtocolStep
      5       , extractValue(value(x2), '/ProtocolStep/Action') as Action
      6       , extractValue(value(x3), '/string') as ParameterList
      7  from tmp_xml t
      8     , table(xmlsequence(extract(t.object_value, '/Protocols/Protocol'))) x1
      9     , table(xmlsequence(extract(value(x1), '/Protocol/ProtocolSteps/ProtocolStep'))) x2
     10     , table(xmlsequence(extract(value(x2), '/ProtocolStep/ParameterList/string'))) x3
     11  ;
    
    PROTOCOL_NAME             REVISION   PROTOCOLSTEP_NAME  ENUMPROTOCOLSTEP   ACTION         PARAMETERLIST
    ------------------------- ---------- ------------------ ------------------ -------------- -------------------
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    SampleDispVol
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    SampleOverAspVol
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    LeadAirGap
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    TrailAirGap
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    SPPumpAspSpeed
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    SPPumpDispSpeed
    SampleAddition_Outer      0          SampleAddition     SampleAddition     SampleProbe    SPPumpDispHeight
    
    7 rows selected
     
    

    Assuming you're on 10.2 you can use XMLTable as well, easier to implement IMO, but on a large XML document may not perform as well as XMLSequence if the XMLType table is not based on a schema.
    Major improvements in the treatment of the XQuery were made from 11 g when using tables not based on a schema.

  • Using subselect XMLType, performance issues

    Hello!

    I want to use an XMLType to store various parameters in our software. However, when you use XMLType in a join, as I do, we get huge response times.

    Select takes ~ 4 minutes to run using XMLType in the join.

    I tried to create a temptable (ab_map_order) and use it to join and the select statement runs in 1 second.

    Y at - it another way to use XMLType in the join, or I have to create a temporary table?

    Help much appreciated!
    / Andreas

    -Tables (the name and the columns have been renamed to hide what they do actually)
    CREATE TABLE AB_CONTROL_SETTINGS)
    CONTROL_SETTINGS_ID NUMBER (10) NOT NULL,
    SYS SETTINGS_XML. XMLTYPE,
    SETTINGS_NAME VARCHAR2 (128 CHAR) NOT NULL
    );

    CREATE TABLE AB_COMPANY)
    COMPANY_ID int,
    company_name varchar (255)
    );

    -Insert values
    INSERT INTO AB_COMPANY VALUES (3456, '3456');

    INSERT INTO AB_CONTROL_SETTINGS VALUES (5, XMLType ("< parameters >
    < order >
    < > 234 order_id < / order_id >
    < company > 3456 < / company >
    < / order >
    < order >
    < > 4563 order_id < / order_id >
    < company > 5674 < / company >
    < / order >
    ((< / Parameter > '), 'ORDER');

    -Select with performance problems (no questions in this tiny select however, we have much more data in ab_company) this selection takes about 4 min. That's how I want to do.
    SELECT * from cmp ab_company
    LEFT JOIN (SELECT p.settings_name,
    extractValue (value (order_seq), "/ order/order_id") as order_id,.
    extractValue (value (order_seq), "/ order/company") as a business
    AB_CONTROL_SETTINGS p,
    Table (XMLSequence (p.settings_xml.extract('/settings/order'))) order_seq
    WHERE p.settings_name like ' COMMAND') card ON map.company = cmp.company_name;

    -Create temptable and use it in the join. This selection takes about 1 sec
    create table
    ab_map_order
    as
    (SELECT p.settings_name,
    extractValue (value (order_seq), "/ order/order_id") as order_id,.
    extractValue (value (order_seq), "/ order/company") as a business
    AB_CONTROL_SETTINGS p,
    Table (XMLSequence (p.settings_xml.extract('/settings/order'))) order_seq
    WHERE p.settings_name like 'COMMAND');

    SELECT * from ab_map_order
    LEFT JOIN ab_company ON ab_map_order.company = ab_company.company_name;

    DROP TABLE ab_map_order;

    What version of Oracle you are using.

    Table (xmlsequence... is the old way of doing XML tables, while the most recent method is to use the XMLTABLE construction...

    SELECT *
    from ab_company cmp
         LEFT JOIN (SELECT p.settings_name,
                           o.order_id,
                           o.company
                    FROM AB_CONTROL_SETTINGS p,
                         xmltable('/settings/order'
                                  passing p.settings_xml
                                  columns order_id    number       path '/order/order_id'
                                         ,company     varchar2(30) path '/order/company'
                                 ) o
                    WHERE p.settings_name = 'ORDER') map
         ON map.company=cmp.company_name;
    

    This can help in the exercise (no guarantee that we do not have your test data and do not know your tables or indexes).
    Note: I changed SIMILAR a '=' because there is no generic characters in your string.

  • Parse XML and insert into the table Oracel

    Hi all

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

    This is the XML code that I have.

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

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

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

    < to > < /pour > USD

    < amount > 1.0 < / amount >

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

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo >


    Here is the code I use to analyze the values

    DECLARE

    XMLType x: = XMLType)

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

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

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

    < to > < /pour > USD

    < amount > 1.0 < / amount >

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

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo > '

    );

    BEGIN

    FOR r IN

    (

    SELECT

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

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

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

    Of

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

    )

    LOOP

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

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

    END LOOP;

    END;

    I get the error message below

    Error report:

    ORA-31011: XML parsing failed

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

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

    Error on line 1

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

    ORA-06512: at line 2

    31011 00000 - "XML parsing failed"

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

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

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

    Appreciate your time and your help.

    Thank you

    Olivier

    Have you even tried to do what we have suggested?

    SQL > ed
    A written file afiedt.buf

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

    13

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

    1 selected line.

Maybe you are looking for

  • It cannot display the task - Virus bar/Manager?

    HelloThanks to toshiba for giving me the opportunity to speak with computernautes.Here's my question: I am running microsoft windows xp home edition with service PAC 2. until recently, I could access the Manager of tasks by the various today methods.

  • T420 how to turn on graphics card

    Hello I was experimenting with configuratition in windows 7 and I turnd off the coast of the graphics card. Now when I turn the t420 screen is black boot. I tried to get into the bios with the f1, but the screen is all black too. How can I activate g

  • HP Pavilion dv6-7140ez

    Hello I just got my new laptop, to say that I am very disappointed with HP web site would be understatement... OK, if you want to change my HD to a SSD, so installed and clone, but due to the amount of things in the other partition I have just re ins

  • Problem with Simulink model dll running on target RT

    Hello! At the beginning I specify software and hardware that I use: LabVIEW 8.5 Simulation Interface Toolkit 4.0.0 Microsoft Visual C++ 6.0 MATLAB 7.4.0 (R2007a) NEITHER cRIO-9014 At first, I did a simple Simulink model (Sine generator, gain and an o

  • scanning and emailing multidocument

    I use a s 6830 model HP laptop with Windows Vista op system Business and a model HP 6210 all-in-one printer, Fax, Scanner, copier. I'm having a problem scanning and e-mailing several pages of a document. Some of my recipients receive all pages OK but