XMLType.extract: result of split

Hello

I use this function of the soap_api.sql for web services.
FUNCTION get_return_value(p_response   IN OUT NOCOPY  t_response,
                          p_name       IN             VARCHAR2,
                          p_namespace  IN             VARCHAR2)
  RETURN VARCHAR2 AS
-- ---------------------------------------------------------------------
BEGIN

        RETURN p_response.doc.extract('//'||p_name||'/child::text()',p_namespace).getstringval();

END;
The problem is that it returns a large number of values, and they are all concatenated to the return value. Is there a way to divide all values with a separator or something?

For example. It returns "TexasLos AngelesChicagoPhoenix" and I would like something like "Texas; Los Angeles; Chicago; Phoenix»

I am using Oracle 11g

Thank you

Hello

You can use the XMLQuery function and string-join (XPath 2.0).

For example:

SQL> DECLARE
  2
  3   xmldoc xmltype := xmltype(
  4  '
  5  Texas
  6  Los Angeles
  7  Chicago
  8  Phoenix
  9  '
 10  );
 11
 12   p_name      VARCHAR2(30) := 'city';
 13   p_namespace VARCHAR2(100) := 'test';
 14
 15   v_result    VARCHAR2(100);
 16
 17  BEGIN
 18
 19   select xmlcast(
 20    xmlquery(
 21     ( 'declare default element namespace "'||p_namespace||'"; (::)
 22       string-join(//'||p_name||'/child::text(),";")' )
 23     passing xmldoc
 24     returning content
 25    )
 26    as varchar2(100)
 27   ) into v_result
 28   from dual;
 29
 30   dbms_output.put_line(v_result);
 31
 32  END;
 33  /

Texas;Los Angeles;Chicago;Phoenix

PL/SQL procedure successfully completed
 

It works well on 11.2, not sure about 11.1.

Another way, by blocking the part extracted outside XQuery.
Perhaps it fits better into your actual design:

SQL> DECLARE
  2
  3   xmldoc xmltype := xmltype(
  4  '
  5  Texas
  6  Los Angeles
  7  Chicago
  8  Phoenix
  9  '
 10  );
 11
 12   p_name      VARCHAR2(30) := 'city';
 13   p_namespace VARCHAR2(100) := 'xmlns="test"';
 14
 15   v_result    VARCHAR2(100);
 16
 17  BEGIN
 18
 19   select xmlcast(
 20    xmlquery(
 21     'string-join(//text(),";")'
 22     passing extract(xmldoc, '//'||p_name, p_namespace)
 23     returning content
 24    )
 25    as varchar2(100)
 26   ) into v_result
 27   from dual;
 28
 29   dbms_output.put_line(v_result);
 30
 31  END;
 32  /

Texas;Los Angeles;Chicago;Phoenix

PL/SQL procedure successfully completed
 

Tags: Database

Similar Questions

  • XMLType.extract changes data?

    declare

    l_xml xmltype.

    l_xml2 xmltype.

    Start

    l_xml: = xmltype.createxml (xmlData = > bfilename ('XMLDIR2', 'demo.xml'),)

    CSID = > 0,

    schema = > null);

    l_xml2: = l_xml.extract('/UNIVERSITY/PKU/DEP/ART');

    dbms_output.put_line (l_xml. GETSTRINGVAL);

    l_xml2: = l_xml.extract('/UNIVERSITY/PKU/DEP/ART');

    dbms_output.put_line (l_xml. GETSTRINGVAL);

    end;

    the outputs are

    UNIVERSITY <>

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < / UNIVERSITY >

    UNIVERSITY <>

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < / UNIVERSITY >

    Cat demo.xml

    UNIVERSITY <>

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < / UNIVERSITY >

    It seems l_xml changed every time an excerpt is called, why? Thank you very much!!!

    Hello

    I have the same problem on this version:

    BANNER

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

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    PL/SQL Release 11.2.0.1.0 - Production

    CORE 11.2.0.1.0 Production

    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    5 selected lines.

    The problem seems to use createxml and getstringval:

    declare
    
      l_xml   xmltype;
      l_xml2  xmltype;
    
    begin
    
      l_xml  := xmltype.createxml(xmlData => bfilename('XMLDIR2', 'demo.xml'),
                                  csid    => 0,
                                  schema  => null);
    
      dbms_output.put_line('Run 1 (getstringval):');
      dbms_output.put_line(l_xml.getstringval);
      dbms_output.put_line('Run 2 (getstringval):');
      dbms_output.put_line(l_xml.getstringval);
      dbms_output.put_line('Run 3 (getstringval):');
      dbms_output.put_line(l_xml.getstringval);
    
    end;
    /
    

    Here is the result:

    Race 1 (getstringval):

    Race 2 (getstringval):

    Race 3 (getstringval):

    Replace getstringval with getclobval seems to fix the problem.

    By creating the xml as literal does not show the same problem.

    Probably a bug on this version.

    Kind regards.

    Alberto

  • XMLTYPE extract some nodes

    Hello
    < book >
    < book >
    < id > 12 / < ID >
    Oracle < name > < / name >
    < / book >
    < book >
    < id > 15 / < ID >
    < name > net < / name >
    < / book >
    < / books >

    Please how can I retrieve the node containing the oracle book without the order of the element, in 10 g and 11 g

    I mean that the result should be

    < book >
    < id > 12 / < ID >
    Oracle < name > < / name >
    < / book >

    Thanks in advance

    How about using the EXTRACT with following XPath function? :
    book/books / [name = 'oracle']

    The whole sample test case:
    ------------------------------------------------------------
    CREATE TABLE testtab)
    ID NUMBER PRIMARY KEY,
    XML XMLTYPE
    );
    INSERT INTO testtab VALUES (1, XMLTYPE ('))

    12
    Oracle


    15
    NET

    '));
    COMMIT;

    SELECT EXTRACT (xml, '/ books/book [name = "oracle"]') FROM testtab;
    ------------------------------------------------------------

  • XMLType extract help function

    I have the example of XML structure below.
    It has 2 child elements of type '< ns0:ItemMetaData >', has all first under element ' < ns0:ItemId > DSLGP603 < / ns0:ItemId > ' and second element sub "< ns0:ItemId > DSLGP603NY < / ns0:ItemId >.
    But it is the only example of 2 parts in stock, there may be 10 these xml inside the chain elements.
    How can I go/loop through all these elements '< ns0:ItemMetaData > '?
    I think I need to change this part:
    extract('//*'
    But I have not managed to change.

    --
    select *
      from xmltable ('*/text()'
                     passing xmltype ('<ns0:FindItemMetaDataResponse xmlns:ns0="http://elion.ee/webservices/Sales/Dynamics">
      <ns0:ItemMetaData>
        <ns0:ItemMetaData>
          <ns0:ItemGroupId>IT.LS.VS.DSL</ns0:ItemGroupId>
          <ns0:ItemGroupName>IT lisad võrguseadmed DSL</ns0:ItemGroupName>
          <ns0:ItemId>DSLGP603</ns0:ItemId>
          <ns0:ItemName>ADSL SIP ST546</ns0:ItemName>
          <ns0:ItemType>Item</ns0:ItemType>
          <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
          <ns0:SalesUnit>tk</ns0:SalesUnit>
          <ns0:SerialNumMandatory>No</ns0:SerialNumMandatory>
          <ns0:TaxValue>20.00</ns0:TaxValue>
        </ns0:ItemMetaData>
        <ns0:ItemMetaData>
          <ns0:CurrencyCode>EUR</ns0:CurrencyCode>
          <ns0:ItemGroupId>KL.PS.HGW</ns0:ItemGroupId>
          <ns0:ItemGroupName>Ruuterid</ns0:ItemGroupName>
          <ns0:ItemId>DSLGP603NY</ns0:ItemId>
          <ns0:ItemName>ADSL stardikomplekt Thomson ST546 stardi</ns0:ItemName>
          <ns0:ItemType>Item</ns0:ItemType>
          <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
          <ns0:PriceWithoutVAT>12.78</ns0:PriceWithoutVAT>
          <ns0:PriceWithVAT>15.34</ns0:PriceWithVAT>
          <ns0:SalesUnit>tk</ns0:SalesUnit>
          <ns0:SerialNumMandatory>Yes</ns0:SerialNumMandatory>
          <ns0:TaxValue>20.00</ns0:TaxValue>
        </ns0:ItemMetaData>
      </ns0:ItemMetaData>
    </ns0:FindItemMetaDataResponse>').extract('//*', 'xmlns="' || 'http://elion.ee/webservices/Sales/Dynamics' || '"')
                    )
    IT.LS.VS.DSL
    IT lisad võrguseadmed DSL
    DSLGP603
    ADSL SIP ST546
    Item
    No
    tk
    No
    20.00
    EUR
    KL.PS.HGW
    Ruuterid
    DSLGP603NY
    ADSL stardikomplekt Thomson ST546 stardi
    Item
    No
    12.78
    15.34
    tk
    Yes
    20.00
    select * from v$version;
    
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE     11.2.0.3.0     Production"
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

    Should I then run the function "extract()" for each element node "" ItemMetaData"" sub I guess?

    You can add other columns as you wish:

    SQL> with sample_data (doc) as (
      2    select xmlparse(document
      3    '
      4    
      5      
      6        IT.LS.VS.DSL
      7        IT lisad võrguseadmed DSL
      8        DSLGP603
      9        ADSL SIP ST546
     10        Item
     11        No
     12        tk
     13        No
     14        20.00
     15      
     16      
     17        EUR
     18        KL.PS.HGW
     19        Ruuterid
     20        DSLGP603NY
     21        ADSL stardikomplekt Thomson ST546 stardi
     22        Item
     23        No
     24        12.78
     25        15.34
     26        tk
     27        Yes
     28        20.00
     29      
     30    
     31  ')
     32    from dual
     33  )
     34  select x.*
     35  from sample_data t
     36     , xmltable (
     37         xmlnamespaces(default 'http://elion.ee/webservices/Sales/Dynamics')
     38       , '/FindItemMetaDataResponse/ItemMetaData/ItemMetaData'
     39         passing t.doc
     40         columns item_id   varchar2(30) path 'ItemId'
     41               , item_name varchar2(80) path 'ItemName'
     42       ) x
     43  ;
    
    ITEM_ID                        ITEM_NAME
    ------------------------------ --------------------------------------------------------------------------------
    DSLGP603                       ADSL SIP ST546
    DSLGP603NY                     ADSL stardikomplekt Thomson ST546 stardi
     
    
  • Teachers Pension extraction process - extract results table

    Hi gurus,

    Please help us to find the table of results retrieved for the process to extract teachers pension for the legislation of the United Kingdom.

    Thank you
    Rambaud

    Not sure about the table names, but you can see how it is set up on the screen of the extract system and mark it

    Clive

  • XMLType extract query

    Hello:

    How to change the following query to get only the element with a given person_id? Actually, I have a CLOB containing an XML document. I thought that step 1 is to create a view, or something that casts of this column to an XMLType object, so I do that in the data of test here as well. If I do not need to do, it makes it very well.
    with base as ( -- Base XML
        select '<?xml version="1.0" encoding="UTF-8"?>
        <person_record_set>
        <person>
        <lname>Doe</lname>
        <fname>John</fname>
        <person_id>12345</person_id>
        </person>
        <person>
        <lname>Smith</lname>
        <fname>John</fname>
        <person_id>54321</person_id>
        </person>
        <person>
        <lname>Jones</lname>
        <fname>Mary</fname>
        <person_id>33333</person_id>
        </person>
        </person_record_set>' bdata
    from dual
    ),
    Q1 as ( -- We want it as an XMLType
    select xmltype(bdata) xtdata 
    from base)
    -- End of test data setup
    select '<rows>' || extract(xtdata,'//person') || '</rows>' from Q1
    Thank you

    You can use conditions on the xpath:

    with q1 as (select xmltype('
        
        
        Doe
        John
        12345
        
        
        Smith
        John
        54321
        
        
        Jones
        Mary
        33333
        
        ') xtdata from dual)
    -- End of test data setup
    select '' || extract(xtdata,'//person[person_id=12345]') || '' from Q1
    

    I don't like particularly the addition of '', though; that's what you do with this data? There are probably better ways to do this.

    Published by: Boneist on May 16, 2012 14:55

  • A parameter of xmltype extraction problem

    Hello
    I am using oracle 11g and I am trying to use an xmltype as input to an SP parameter, here's my SP:

    create or replace PROCEDURE ABC
    (FE_Param OF XMLType)
    AS
    BEGIN
    I'm IN
    (
    SELECT XMLTYPE. EXTRACT (VALUE (a),
    ' Root/FE_ID/text()').getstringval (LIKE FE_ID)
    TABLE
    (XMLSEQUENCE (FE_Param.EXTRACT
    ("/ FEData/Root")
    ) ) a )

    LOOP
    INSERT INTO table1
    VALUES (i.FE_ID);
    END LOOP;

    The XML parameter looks like this:
    <? XML version = "1.0" encoding = "utf - 8"? >
    < FEData >
    < root > < FE_ID > 900000031 < / FE_ID >
    < FE_ID > 900000032 < / FE_ID > < FE_ID > 900000050 < / FE_ID > < / root > < / FEData >

    Triple post - what's happened? :-)

    Published by: Kim Berg Hansen on August 22, 2011 16:47

  • XMLType.extract cannot display French special characters in the select statement

    Hello
    E characters (acute e) get distorted when they are retrieved from the
    XMLType column of an ordinary table.

    How can we solve correctly get the characters e (acute e)?

    We tried setting 'setenv NLS_LANG French_France.WE8ISO8859P1' and
    "setenv NLS_LANG French_France.WE8DEC" before loading the table.

    Database version:
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    The test sample case is as follows:
    --connect to any schema where you can store XMLType
    set long 2000;
    set pagesize 2000;
    set serveroutput on;
    --delete from test;
    drop table test;
    create table test (id number, xmldata XMLType);
    
    
    declare
    featureDescriptorXML  CLOB;
    xml_type XMLType;
    new_xml_type XMLType;
    myName varchar2(100);
    myName2 varchar2(100);
    myName3 varchar2(100);
    stmt varchar2(4000);
    begin
     featureDescriptorXML :=
     '<?xml version="1.0" encoding="UTF-8"?>' ||
     '<abc:TheFeature xmlns:' || 'de' || '="' || 'http://abc.klmno.org/fghde' || '" xmlns:abc="http://www.ghijklmn.net/abc"' ||
     ' xmlns:xyz="http://www.ghijklmn.net/xyz">' ||
     '<abc:Name>de:MyGénérique</abc:Name>' ||
     '</abc:TheFeature>';
     xml_type := xmltype(featureDescriptorXML);
     myName := xml_type.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal();
     dbms_output.put_line('abc:Name value stored in VARCHAR2 variable from XMLType variable is ' || myName);
     -- can show French chars
    
     insert into test(id, xmldata) values(20, xml_type);
    
     stmt := 'select t.xmldata.extract(''/abc:TheFeature/abc:Name/text()'', ''xmlns:abc="http://www.ghijklmn.net/abc"'').getStringVal() from test t';
     execute immediate stmt into myName2;
     dbms_output.put_line('abc:Name value stored in VARCHAR2 variable from XMLType column in 2nd version is ' || myName2);
     -- cannot show French chars
    
    
     stmt := 'select  t.xmldata from test t';
     execute immediate stmt into new_xml_type;
     myName3 := new_xml_type.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal();
     dbms_output.put_line('abc:Name value stored in VARCHAR2 variable from first XMLType column and then from XMLType variable in 3rd version is ' || myName3);
     -- cannot show French chars
    
    end;
    /
    
    select t.xmldata.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal()
    from test t;
    -- Cannot show French chars
    
    
    select t.xmldata.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal() "myname"
    from test t;
    -- Cannot show French chars
    
    
    select t.xmldata.getCLOBVal() from test t;
    -- Cannot show French chars
    
    
    select t.xmldata from test t;
    -- Can show French chars
    Output is the following with setenv NLS_LANG French_France.WE8ISO8859P1
    and NLS_DATABASE_PARAMETERS are the following:
    SQL> select * from nls_database_parameters;
    
    PARAMETER                      VALUE
    ------------------------------ ----------------------------------------
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               WE8DEC
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    
    PARAMETER                      VALUE
    ------------------------------ ----------------------------------------
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_RDBMS_VERSION              11.2.0.2.0
    
    20 ligne(s) sélectionnée(s).
    Table creé.
    
    abc:Name value stored in VARCHAR2 variable from XMLType variable is
    de:MyGénérique
    abc:Name value stored in VARCHAR2 variable from XMLType column in 2nd version is
    de:MyGénérique
    abc:Name value stored in VARCHAR2 variable from first XMLType column and then
    from XMLType variable in 3rd version is de:MyGénérique
    
    Procdure PL/SQL terminée avec succès.
    
    
    T.XMLDATA.EXTRACT('/ABC:THEFEATURE/ABC:NAME/TEXT()','XMLNS:ABC="HTTP://WWW.GHIJK
    --------------------------------------------------------------------------------
    de:MyGénérique
    
    
    myname
    --------------------------------------------------------------------------------
    de:MyGénérique
    
    
    T.XMLDATA.GETCLOBVAL()
    --------------------------------------------------------------------------------
    <?xml version="1.0" encoding="DEC-MCS"?>
    <abc:TheFeature xmlns:de="http://abc.klmno.org/fghde" xmlns:abc="http://www.ghij
    klmn.net/abc" xmlns:xyz="http://www.ghijklmn.net/xyz">
      <abc:Name>de:MyGénérique</abc:Name>
    </abc:TheFeature>
    
    
    
    XMLDATA
    --------------------------------------------------------------------------------
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <abc:TheFeature xmlns:de="http://abc.klmno.org/fghde" xmlns:abc="http://www.ghij
    klmn.net/abc" xmlns:xyz="http://www.ghijklmn.net/xyz">
      <abc:Name>de:MyGénérique</abc:Name>
    </abc:TheFeature>
    We also tried affecting NLS_CHARACTERSET AL32UTF8
    by CHARACTER SET of ALTER DATABASE.
    the database is closed and restarted.
    But that did not help.

    Thank you

    Ok. Wasn't sure. Thank you for that clarification.

    .. .but please make an attempt with XMLTABLE XMLQUERY, XMLCAST (or CAST) and other XML functions that support XQuery and not to use the engine of 'old '... I hope that these features will keep things as it should...

    .. .If not... create an SR with support of Oracle on this issue. Changes, if you base your SR on these 'old' operators XML/SQL and functions that are her will not be able to help, mainly due to the fact that your last version and stuff like EXTRACT / getStringVal() etc. are announced officially discouraged in this 11.2.0.2.0 version. As far as I know the t.xmldata.extract, the xml_type.extract and the other syntaxes, outlaw count of 10.1 (although I know, he appealed to java / OO people kind).

    Published by: Marco Gralike April 5, 2011 19:50

  • Results of split in blocks of 30 minutes

    Hello

    I analyze our table of concurrent requests to look to see where it might be the quietest time of the day for me to do a few hours of work.

    I was wondering if there is anyway I can do?

    Some examples of data, with an ideal outing:

    [code] WITH limitdata AS

    (SELECT code 1234, TO_DATE (11 January 2014 05:32:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 1' job_name FROM DOUBLE UNION ALL)

    SELECT ID 1235, TO_DATE (11 January 2014 05:42:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 2' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1236, TO_DATE (11 January 2014 05:57:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 3' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1237, TO_DATE (11 January 2014 07:12:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 4' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1238, TO_DATE (11 January 2014 07:22:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 5' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1239, TO_DATE (11 January 2014 07:52:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, 'name 6' job_name FROM DOUBLE UNION ALL employment.

    SELECT ID 1240, TO_DATE (11 January 2014 09:12:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 7' job_name FROM DOUBLE UNION ALL.

    SELECT the ID of 1241, TO_DATE (11 January 2014 09:22:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 8' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1242, TO_DATE (11 January 2014 09:22:49 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 9' job_name FROM DOUBLE UNION ALL.

    1243 SELECT ID, TO_DATE (11 January 2014 09:25:30 ',' ' the HH24: MI: SS DD-MM-YYYY) dt, "job name 10' job_name FROM DUAL).

    SELECT * FROM limitdata;

    Ideal outing:

    FROM THE DATE OF

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

    11 JANUARY 2014 05:30 - 05:59 3

    11 JANUARY 2014 06:00 - 06:29 0

    11 JANUARY 2014 06:30 - 06:59 0

    11 JANUARY 2014 07:00 - 07:29 2

    11 JANUARY 2014 07:30 - 07:59 1

    11 JANUARY 2014 08:00 - 08:29 0

    11 JANUARY 2014 08:30 - 08:59 0

    11 January 2014 09:00 - 09:29 4 [/ code]

    Any advice would be much appreciated.

    Thank you!

    Try this:

    WITH limitdata AS

    (SELECT code 1234, TO_DATE (11 January 2014 05:32:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 1' job_name FROM DOUBLE UNION ALL)

    SELECT ID 1235, TO_DATE (11 January 2014 05:42:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 2' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1236, TO_DATE (11 January 2014 05:57:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 3' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1237, TO_DATE (11 January 2014 07:12:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 4' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1238, TO_DATE (11 January 2014 07:22:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 5' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1239, TO_DATE (11 January 2014 07:52:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, 'name 6' job_name FROM DOUBLE UNION ALL employment.

    SELECT ID 1240, TO_DATE (11 January 2014 09:12:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 7' job_name FROM DOUBLE UNION ALL.

    SELECT the ID of 1241, TO_DATE (11 January 2014 09:22:45 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 8' job_name FROM DOUBLE UNION ALL.

    SELECT ID 1242, TO_DATE (11 January 2014 09:22:49 ',' ' DD-MM-YYYY HH24:MI:SS) dt, "job name 9' job_name FROM DOUBLE UNION ALL.

    1243 SELECT ID, TO_DATE (11 January 2014 09:25:30 ',' ' the HH24: MI: SS DD-MM-YYYY) dt, "job name 10' job_name FROM DUAL).

    , pieces as (select rownum as chnk_no

    0 (86400/48) * (rownum-1) as secs_from

    0 (86400/48) *-1 as secs_to rownum

    of the double

    connect by rownum<=>

    D SELECT

    tfrom

    tto

    COUNT (id) as cntr

    FROM (select TO_CHAR (x.dt,' JJ.)) MM YYYY') d

    , TO_CHAR (x.dt + c.secs_from/86400, 'HH24:MI') as tfrom

    TO_CHAR (x.dt + c.secs_to/86400, 'HH24:MI') as tto

    c.chnk_no

    l.id

    large pieces c

    CROSS join (SELECT distinct TRUNC (dt) dt OF limitdata) x

    Join external limitdata l left (TRUNC (l.dt) = x.dt

    AND to_number (to_char (l.dt, 'SSSSS')) BETWEEN c.secs_from and c.secs_to)) x

    GROUP by d, tfrom, tto chnk_no

    ORDER BY d, chnk_no

    /

    HTH

  • Dates of Split on quarterly basis

    I have a requirement in which I divide the dates in the quarterfinals. It should start from the continuous first_date on the last day of the quarterly month and end at last_date.

    () AS T

    SELECT TO_DATE (' 02/03/2012 ',' DD/MM/YYYY') FIRST_DATE, TO_DATE('26/05/2013','DD/MM/YYYY') DOUBLE LAST_DATE)

    SELECT * FROM T

    The quarterly result of split I want should look like this-

    FIRST_DATE LAST_DATE

    02/03/2012-30/06/2012

    01/07/2012-31/10/2012

    01/11/2012-28/02/2014

    01/03/2014 26/05/2013

    Thank you

    Just like that.

    () AS T

    SELECT TO_DATE (' 02/03/2012 ',' DD/MM/YYYY') FIRST_DATE, TO_DATE('26/05/2013','DD/MM/YYYY') DOUBLE LAST_DATE)

    SELECT CASE WHEN LEVEL = 1

    THEN FIRST_DATE

    OF ANOTHER LAST_DAY (ADD_MONTHS (TRUNC (FIRST_DATE, 'MONTH'), ((LEVEL-1) * 4)-1)) + 1 END AS FIRST_DATE,.

    BOX WHEN LEVEL! = (SELECT MAX (LEVEL) FROM CONNECT BY LEVEL)<=>

    THEN LAST_DAY (ADD_MONTHS (TRUNC (FIRST_DATE, 'MONTH'),(LEVEL*4)-1))

    OF ANOTHER LAST_DATE END AS LAST_DATE

    T

    CONNECT BY LEVEL<=>

    OUTPUT:

    FIRST_DAT LAST_DATE

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

    MARCH 2, 12 JUNE 30, 12

    JULY 1, 12 OCTOBER 31, 12

    NOVEMBER 1ST, 12 FEBRUARY 28, 13

    MARCH 1ST, 13 26 MAY 13

  • Question about "split partition" command

    Hello

    I have the following partitioned table...

    CREATE TABLE trans_tab
    (

    TRANS_ID number (10),
    DATE OF TRANS_DATE,
    CONSTRAINT PK_TRNS_ID PRIMARY KEY (TRANS_ID))
    PARTITION BY RANGE (TRANS_DATE)
    (PARTITION TRANS_2010 VALUES LESS THAN (TO_DATE ("2010-10-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN '")) TABLESPACE TRANS_2010,)
    PMAX VALUES LESS THAN (MAXVALUE) TABLESPACE TRANS_MAX PARTITION);

    Now, I intend to add a partition, as shown below...

    ALTER table split partition pmax trans_tab at (TO_DATE (' 2012-10-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN ')) in (2012 partition, partition pmax);


    The command above split partition worked well and ended quickly in the TEST environment which had only 100 records. I now intend to do in the production, which has about 90 MM records in the table. Here are my questions...

    (1) I will try to find how long would the "split partition" command to run into a table that has ~ 90 mm record table the command "split partition" to physically move the records or just logically to remap the records to the appropriate partition? If it is logical remapping, I guess that the split command would complement quickly even against a huge table... Could check you?

    (2) in the TEST environment, I checked the non partitioned status of the global and the local index after splitting the partiton and they look good? Should I be rebuild the index after splitting the partition?

    Thanks for your time...

    Assuming he has no line of 2012 year in partition PMAX, the SPLIT would create a vacuum PMAX anew. However, it has the maximum value of TRANS_DATE in the PMAX partition - so he must sweep the partition (or use a LOCAL index on the partition, if available). Therefore, depending on how it can identify lines, it may take a little time.

    I think that the current PMAX partition is not empty (that is, it has lines of 2011). As a result, a SPLIT will cause GLOBAL Indexes to score UNUSABLE unlesss you use the UPDATE GLOBAL INDEXES.

    Was your test with the actual number of lines to PMAX?

    Hemant K Collette

  • 'DV scène Extraction'

    In the Avid, you have the 'DV scène Extraction' function. With DV scene Extraction, you can split your master clip captured, in subitems. (Every time a break or stop the camera signal is detected, we will create a new subitem or will set a new benchmark).

    Is there something similar in Premiere Pro (v5.0)?

    Please enter you!

    Premiere Pro has no automatic way to do this after the capture, in the course.

  • problem with 'xmltype.existsnode '.

    Hi people,

    I'm trying to download a "fairly simple".xml file in db with below the part of the code, but for some reason any that it does not work :(

    No idea what I am doing wrong?

    XML file:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <BulkExportRootElement xmlns:ns2="http://homeoffice.gov.uk/ immigration/migrant/cas/bulk-cas-common-200903" xmlns="http://homeoffice.gov.uk/ immigration/migrant/cas/bulk-cas-export-200903">
      <ExportFileHeader>
        <BulkExportId>152eec86-d151-4fea-affd-e93ab1d05173</BulkExportId>
        <ReportConstructionDate>2009-09-16</ReportConstructionDate>
      </ExportFileHeader>
      <CASExportData>
        <CASNumber>E4G3AA1A09W0A4</CASNumber>
        <CASStatus>ASSIGNED</CASStatus>
        <LastStatusChanged>2009-09-16</LastStatusChanged>
        <ApplicantId>1010101</ApplicantId>
        <FamilyName>Smith</FamilyName>
        <GivenName>John</GivenName>
        <Nationality>AUS</Nationality>
        <DateOfBirth>
          <ns2:FullDate>1980-02-20</ns2:FullDate>
        </DateOfBirth>
        <PassportTravelDocumentNumber>703121021</PassportTravelDocumentNumber>
        <CourseId>13031</CourseId>
        <CourseCurriculumTitle>Iron Age History</CourseCurriculumTitle>
        <CourseStartDate>2010-01-08</CourseStartDate>
        <ExpectedCourseEndDate>2010-02-13</ExpectedCourseEndDate>
      </CASExportData>
      <CASExportData>
        <CASNumber>E4G3AA1A09V0A7</CASNumber>
        <CASStatus>USED</CASStatus>
        <LastStatusChanged>2009-09-16</LastStatusChanged>
        <ApplicantId>1010102</ApplicantId>
        <FamilyName>March</FamilyName>
        <GivenName>Wi</GivenName>
        <Nationality>AUS</Nationality>
        <DateOfBirth>
          <ns2:FullDate>1983-06-25</ns2:FullDate>
        </DateOfBirth>
        <PassportTravelDocumentNumber>PQ254689</PassportTravelDocumentNumber>
        <CourseId>13031</CourseId>
        <CourseCurriculumTitle>Iron Age History</CourseCurriculumTitle>
        <CourseStartDate>2010-01-08</CourseStartDate>
        <ExpectedCourseEndDate>2010-02-13</ExpectedCourseEndDate>
      </CASExportData>
    </BulkExportRootElement>
    my code:
    declare
        p_aplus_ukba_xml_id number := 671601494;
        l_message clob;
    
        l_xmldoc  clob;
        l_xml  xmltype;
    
        e_cannot_parse exception;
      begin
        select xml
          into l_xmldoc  -- a CLOB, where xml file is stored
        from APLUS_UKBA_XML
        where object_id = p_aplus_ukba_xml_id;
        
        
        l_xml  := xmltype.createxml(l_xmldoc);
        
        dbms_output.put_line('START HEADER');
        
        if xmltype.existsnode(l_xml, 'BulkExportRootElement/ExportFileHeader') = 1 then
          dbms_output.put_line('BulkExportRootElement/ExportFileHeader exists');
          dbms_output.put_line( xmltype.extract(l_xml,'BulkExportRootElement/ExportFileHeader/BulkExportId/text()').getstringval()  );
        else
          dbms_output.put_line('BulkExportRootElement/ExportFileHeader NOT exists!');  
        end if;
        
        -- END;
        update APLUS_UKBA_XML
           set job_id = null, 
               timestamp = sysdate,
               status = 'PROCESSED'
         where object_id = p_aplus_ukba_xml_id;
         
      exception
        when e_cannot_parse then
          l_message := 'ap_ukba_upload.process_xml.e_cannot_parse'||CHR(10)||sqlerrm;
          
          update APLUS_UKBA_XML
          set status     = 'ERROR',
              error_desc = l_message,
              job_id     = null,
              timestamp  = sysdate
          where object_id = p_aplus_ukba_xml_id;
          commit;
          raise_application_error(-20333, 'Cannot parse export file');
        when others then
          l_message := sqlerrm;
         update APLUS_UKBA_XML
          set status     = 'ERROR',
              error_desc = l_message,
              job_id     = null,
              timestamp  = sysdate
          where object_id = p_aplus_ukba_xml_id;
          commit;
          raise;
      end;
    OUTPUT:
    START HEADER
    BulkExportRootElement/ExportFileHeader NOT exists!
    As you can see, output says that there is no such thing as "BulkExportRootElement/ExportFileHeader", but based on the XML file, there are.

    Please advise, as I don't see where is the problem.

    Kind regards
    Tomas

    (I used a similar approach in the various projects and no problem)

    you will have something to hope for... ;)
    Try this pending

    with test as
    (select xmltype (
    '
    
      
        152eec86-d151-4fea-affd-e93ab1d05173
        2009-09-16
      
      
        E4G3AA1A09W0A4
        ASSIGNED
        2009-09-16
        1010101
        Smith
        John
        AUS
        
          1980-02-20
        
        703121021
        13031
        Iron Age History
        2010-01-08
        2010-02-13
      
      
        E4G3AA1A09V0A7
        USED
        2009-09-16
        1010102
        March
        Wi
        AUS
        
          1983-06-25
        
        PQ254689
        13031
        Iron Age History
        2010-01-08
        2010-02-13
      
    ') xmlmsg from dual
    )
    select extract (xmlmsg
                   ,'/BulkExportRootElement/ExportFileHeader/BulkExportId/text()'
                   ,'xmlns:ns2="http://homeoffice.gov.uk/immigration/migrant/cas/bulk-cas-common-200903" xmlns="http://homeoffice.gov.uk/immigration/migrant/cas/bulk-cas-export-200903"'
                   ).getStringVal()
      from test
    
  • Helps the Parseing XML

    Version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

    Hello

    I need assistance with an XML file to generate lines to insert into a table staged for further processing.

    There is an XML document that is loaded into a table in the database via a Web Service call.

    I need to query this table to get the XML code, loop through it to create folders, with the fields in a specific order and insert records into a table of staging.

    There are two columns that are not in the XML that are added during the process. I am including these tables as well.

    I know it is a bunch of "stuff", but I hope I've provided enough information to get help.

    The tables and insert queries:

    -This table contains the XML of the Web Service call

    CREATE TABLE exam_results
    (
    CLOB results_clob
    );

    INSERT INTO exam_results (results_clob)
    VALUES
    ("< result > < candidate > < ProgramCandidateID > 911221 < / ProgramCandidateID > < LastName > V361208 < / LastName > < FirstName > J361208 < / FirstName > < / candidate > < event > < ended > 1 < / filled > < CompleteDate > 2011 - 08 - 05T 10: 23:42.957 < / CompleteDate > < FormName > SSU11-05 < / FormName > < NumStarts > 2 < / NumStarts > < ProgramRegistrationID > SU0006510JV < / ProgramRegistrationID > < result > 564865 identifier < / result identifier >") < Sponsor > MySponsor < / sponsor > < StartTime > 2011 - 08 - 05T 08: 22:47.877 < / StartTime > < TestName > SSU11 < / TestName > < / Event > < start > < Start > < BrowserVersion > 8.0 < / BrowserVersion > < OperatingSystem > Windows NT 4.0 < / OperatingSystem > < / Start > < / begins > < Scores > < issues > < > < name > 105103 < / name > < SeqDelivered > 1 < / SeqDelivered > < response > 1 < / response > < key > 4 < / key > < seconds > 169.126 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261292 < / name > < SeqDelivered > 2 < / SeqDelivered > < answer > 3 < / response > < key > 3 < / key > < seconds > 97.984 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261241 < / name > < SeqDelivered > 3 < / SeqDelivered > < response > 3 < / response > < key > 3 < / key > < seconds > 87.579 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261451 < / name > < SeqDelivered > 4 < / SeqDelivered > < answer > 3 < / response > < key > 3 < / key > < seconds > 59.983 < / seconds (> < Section > 1 < / section > < / Question > < Question > < name > 264373 < / name > < SeqDelivered > 5 < / SeqDelivered > < response > 5 < / response > < key > 1 < / key > < seconds > 86.346 < / seconds > < Section > 1 < / Section > < / Question > < / Questions > < / Scores > < / result > ');

    -This table is to get 1 of the additional columns that must be included

    CREATE TABLE tracking_id_tbl
    (
    tracking_id NUMBER,
    customer_id NUMBER,
    launch_code VARCHAR2 (11)
    );

    INSERT INTO tracking_id_tbl (tracking_id, customer_id, launch_code)

    VALUES (557,2296267, 'SU0006510JV');

    -This table is to get the other extra column which must be included

    CREATE TABLE school_code_tbl
    (
    customer_id NUMBER,
    nb_id NUMBER,
    organization_id VARCHAR2 (8)
    );

    INSERT INTO school_code_tbl (customer_id, nb_id, organization_id)

    VALUES (2296267,911221, '12');

    -This table will receive the file created from the XML

    CREATE TABLE staging_tbl
    (
    results_data VARCHAR2 (4000)
    );

    To facilitate the XML file to read (we hope) here is a formatted version:

    < result >

    < candidate >

    < ProgramCandidateID > 911221 < / ProgramCandidateID >

    < name > V361208 < / LastName >

    J361208 < FirstName > < / name >

    < / candidate >

    < event >

    < finish > 1 < / completed >

    < completeDate > 2011 - 08 - 05T 10: 23:42.957 < / CompleteDate >

    SSU11-05 < FormName > < / FormName >

    < NumStarts > 2 < / NumStarts >

    < ProgramRegistrationID > SU0006510JV < / ProgramRegistrationID >

    ID of < result > 564865 < / ID results >

    < sponsor > MySponsor < / sponsor >

    < StartTime > 2011 - 08 - 05T 08: 22:47.877 < / StartTime >

    SSU11 < TestName > < / TestName >

    < / event >

    < start >

    < start >

    < > 8.0 BrowserVersion < / BrowserVersion >

    < OperatingSystem > Windows NT 4.0 < / OperatingSystem >

    < / start >

    < / starts >

    < scores >

    < questions >

    < question >

    < name > 105103 < / name >

    < SeqDelivered > 1 < / SeqDelivered >

    < response > 1 < / answer >

    < Key > 4 < / key >

    < seconds > 169.126 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 261292 < / name >

    < SeqDelivered > 2 < / SeqDelivered >

    < response > 3 < / answer >

    < Key > 3 < / key >

    < seconds > 97.984 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 261241 < / name >

    < SeqDelivered > 3 < / SeqDelivered >

    < response > 3 < / answer >

    < Key > 3 < / key >

    < seconds > 87.579 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 261451 < / name >

    < SeqDelivered > 4 < / SeqDelivered >

    < response > 3 < / answer >

    < Key > 3 < / key >

    < seconds > 59.983 < / seconds >

    article <>1 < / Section >

    < / question >

    < question >

    < name > 264373 < / name >

    < SeqDelivered > 5 < / SeqDelivered >

    < response > 5 < / answer >

    < Key > 1 < / key >

    < seconds > 86.346 < / seconds >

    article <>1 < / Section >

    < / question >

    < / questions >

    < / scores >

    < / result >

    This XML file is for 1 card. There are several issues that are in the file. I reduced to only 5 is easier to see.

    The layout of the document to be inserted in the staging table is:

    Event.TestName

    Event.FormName

    Event.CompleteDate

    v_tracking_id

    Event.ProgramRegistrationID

    Event.StartTime

    Event.CompleteDate / * end * /.

    Candidate.LastName

    Candidate.FirstName

    Candidate.MiddleName (the middle name does not exist in the file XML then return null)

    Candidate.ProgramCandidateID

    v_school_code

    Candidate.CustomProperties.Answer (this does not exist in the file XML then return null)

    Event.ResultID

    Event.NumStarts

    Event.Completed

    Event.Sponsor

    Scores.Questions.Question.Name

    Scores.Questions.Question.Section

    Scores.Questions.Question.SeqDelivered

    Scores.Questions.Question.Key

    Scores.Questions.Question.Answer

    Scores.Questions.Question.Seconds

    Starts.OperatingSystem

    Starts.BrowserVersion

    The expected output is:

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,105103,1,1,4,1,169.126,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261292,1,2,3,3,97.984,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261241,1,3,3,3,87.579,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261451,1,4,3,3,59.983,Windows NT 4.0,8.0");

    INSERT INTO staging_tbl (results_data)
    VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,264373,1,5,1,5,86.346,Windows NT 4.0,8.0");

    The Questions/Question, is what makes a separate line if the values for the other fields would be the same for however many questions is in the XML file.

    That's what I've tried so far:

    DECLARE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             CURSOR get_results_cur
    IS
    SELECT results_clob
    Of exam_results;

    get_results_rec XMLTYPE.
    get_results_clob CLOB.
    NUMBER (38) v_count: = 1;


    v_result VARCHAR2 (32000);
    v_tracking_id tracking_id.tracking_id_tbl%TYPE;
    v_school_code organization_id.school_code_tbl%TYPE;

    BEGIN
    OPEN get_results_cur.
    SEEK get_results_cur INTO get_results_clob;
    CLOSE Get_results_cur;

    get_results_rec: = xmltype.createxml (get_results_clob);

    SELECT tracking_id
    school_code
    IN v_tracking_id
    v_school_code
    OF ti tracking_id_tbl
    JOIN school_code_tbl ON ti.customer_id = sc.customer_id sc
    WHERE ti.launch_code = get_results_rec. EXTRACT ('/ Result/Event/ProgramRegistrationID/text()').getstringval () AND)
    nb_id = get_results_rec. EXTRACT ('/ Result/Candidate/ProgramCandidateID/text()').getstringval ();)

    While get_results_rec. EXISTSNODE ('/ / result [' | v_count |]) ']') = 1
    LOOP
    v_result: =.
    (get_results_rec. EXTRACT ('/ results/event/TestName [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/FormName [' | v_count | / text () ']) .getstringval ())
    || ','
    || ((get_results_rec. EXTRAIT ('/ résultats/événement/CompleteDate [' || v_count || / text () SUBSTR']) .getstringval ()), 1, 10)
    || ','
    || v_tracking_id
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/ProgramRegistrationID [' | v_count | / text () ']) .getstringval ())
    || ','
    || ((get_results_rec. EXTRAIT ('/ résultats/événement/StartTime [' || v_count || / text () SUBSTR']) .getstringval ()), 12.8)
    || ','
    || ((get_results_rec. EXTRAIT ('/ résultats/événement/CompleteDate [' || v_count || / text () SUBSTR']) .getstringval ()), 12.8)
    || ','
    || (get_results_rec. EXTRACT ('/ result/candidate/name [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ result/candidate/name [' | v_count | / text () ']) .getstringval ())
    || ',,'
    || -(get_results_rec. Extract('/result/candidate/MiddleName [' || v_count ||) '] / text () ') .getStringVal ()); ',' ||
    (get_results_rec. EXTRACT ('/ result/candidate/ProgramCandidateID [' | v_count | / text () ']) .getstringval ())
    || ','
    || v_school_code
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/result identifier [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/NumStarts [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/completed [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ results/event/sponsor [' | v_count | / text () ']) .getstringval ());
    || ','

    -Add the results of the first question

    || ','
    || (get_results_rec. EXTRACT ('/ result, departures, Start, OperatingSystem [' | v_count | / text () ']) .getstringval ())
    || ','
    || (get_results_rec. EXTRACT ('/ result, departures, Start, BrowserVersion [' | v_count | / text () ']) .getstringval ());

    v_count: = v_count + 1;

    INSERT INTO staging_tbl (results_data)
    VALUES (v_result);

    END LOOP;
    END;

    What can clear?

    Thank you

    Joe

    You have several questions in the XML, so when flattened document you will have several lines trying to extract in v_result.  Where the error.  You will need to either loop

    for rec in (select... from XMLTable...)

    loop

    insert into staging_tbl...

    end loop;

    or make an insert select

    insert into staging_tbl (results_data)

    Select...

    from XMLTable...

  • Loading XML into the relational Table data

    Hello

    I get a generated XML file to other tools (Windows), I am trying to create a Linux shell script that will gather the necessary XML file to my Linux server, then ask Oracle to use this file to load the XML data into a relational table. This activity and the data will be needed on an ongoing basis.

    I tried two ways. First, I loaded the XML document into the database and tried to extract the data directly from the document, but it does not work. Now I want to try to read the data directly from the file on the server through select, however I don't get all the returned data. In the Select statement below, I am trying to query the data to see what is returned for my tests.

    Create Table ci_results_table (transactionID Varchar2 (100), //transactionID should be PrimaryKey but became errors in test of insert, PK so deleted NULL value)

    message Varchar2 (200),

    This Varchar2 (50).

    XMLType of the ProcessedDate,

    status Varchar2 (50).

    sourceFile VarChar2 (100));

    Select x.*

    from XMLTable)

    ' TSPLoadResults/results '.

    PASSAGE xmltype (bfilename('CMDB_DEVADHOCRESULTS_DIR','LoadResults-HP_146.results.xml'), nls_charset_id ('AL32UTF8'))

    COLUMNS

    transactionID PATH Varchar2 (100) 'TransactionID '.

    Result XMLType PATH 'result ',.

    Message Varchar2 (200) PATH "Message."

    PrimaryKey Varchar2 (50) PATH "PrimaryKey"

    Date of ProcessedDate path "ProcessedDate."

    Status Varchar2 (50) PATH "Status."

    SourceFile VarChar2 (100) PATH "SourceFileName.

    ) x

    ;

    Eventually, I'll have to build on that to limit the returned data to records where SourceFileName is like '% PA' and insert what is returned in to the ci_results_table. Attached is an example of the XML results file I am trying to load, it is named "ResultsTransformedtoUnix" because I used dos2Unix to convert Unix which can be good or bad. (I send the output file must be converted to the format BACK until the other application can read). Original (before converting Unix) file named in the script is also attached.

    Help, please. Thank you!

    Hello

    I see some bad things in your query.

    (1) obvious one, explaining why you get all the data: there is a typing error in the XQuery expression, there 'result' not'slead.

    (2) ProcessedDate can be extracted as a date (at least not directly) because it actually represents a timestamp, use the TIMESTAMP WITH time ZONE HOURS and cast back to DATE data type in the SELECT clause

    (3) transactionID is an attribute, it must be accessible with ' @' (or ' attribute:' axis)

    (4) if the encoding of file really is ISO-8859-1 as suggested in the prologue, then do not use AL32UTF8 but the name of the corresponding character set: WE8ISO8859P1

    Here is the query to work:

    select x.transactionID
         , x.Message
         , x.Primarykey
         , cast(x.ProcessedDate as date) ProcessDate
         , x.Status
         , x.SourceFile
    from XMLTable(
           '/TSPLoadResults/Result'
           PASSING xmltype(bfilename('XML_DIR','LoadResults-HP_146.results.xml'), nls_charset_id('WE8ISO8859P1'))
           COLUMNS
             transactionID Varchar2(100)            PATH '@transactionID',
             Message       Varchar2(200)            PATH 'Message',
             PrimaryKey    Varchar2(50)             PATH 'PrimaryKey',
             ProcessedDate timestamp with time zone PATH 'ProcessedDate',
             Status        Varchar2(50)             PATH 'Status',
             SourceFile    VarChar2(100)            PATH 'SourceFileName'
         ) x
    ;
    

    Directly on the file using this query will only be decently (for large files) on 11.2.0.4 and beyond.

    On older versions, first load the file into a (temporary) XMLType column with binary XML storage and CHOOSE from there.

    because I used dos2Unix to convert Unix which can be good or bad.

    This conversion should not be necessary.

Maybe you are looking for

  • Random imap account appeared on the iPhone

    Hoping someone can help - suddenly appeared random imap account recently on my iPhone!  It's a story of the minbox.email and the description is "who will marry you."  When I check the account in my email application, there are a bunch of junk.  The a

  • Windows upgrade keeps sending same update

    Update for windows Vista Home Basic. XML Core Services 4.0 Service Pack 2 (KB954430)Sent me 7 times 7 times each properly installed have yet been sent even.

  • Can not see the drive letter for Hammer 640 GB external hard drive

    I have an external hammer 640 GB drive (which has a Western Digital WD6400AAKS drive inside) with important data. When I connect to my computer (under Windows XP Pro), I can see the player if I go to my computer-> hardware-> readers but can see any d

  • Hotmail sign in assistant

    WHY THE MULTIPLES OPTION FOR HOTMAIL SIGN HAS NOT POSTED

  • Circumvention of password

    I forgot my password can you tell me how to get around to turn on computor