Inserting XML data in xmltype column

Oracle version: 10.1.0.5
OpenVms Alpha V8.3

(1) tried this and getting the error below. Place a zero and remove charset. Same mistake.

INSERT INTO xml_demo (donnees_xml) - xmltype column
VALUES
(
XmlType
(
BFILENAME ('XML_DIR ',' MOL.) XML').
nls_charset_id ('AL32UTF8')
),
);


ORA-22993: much of the specified input is greater than the quantity real source
ORA-06512: at "SYS." DBMS_LOB", line 637
ORA-06512: at "SYS." XMLTYPE", line 283
ORA-06512: at line 1


(2) this PL/SQL block works. However maximum brute size about 32K. The file may be around 100 K. May be I can load into a table of raw and somehow concatnate to insert. Not sure if it's possible, but I'm sure there must me a simple way to do this.

Subset of the xml file is pasted below.


Set serveroutput size 1000000
DECLARE
bfile file1;
XMLType v_xml;
len1 number (6);
v_rec1 raw (32000);

BEGIN
File1: = bfilename ('XML_DIR ',' MOL.) XML');
DBMS_LOB. FileOpen (File1, DBMS_LOB.file_readonly);
len1: = DBMS_LOB.getLength (file1);
v_rec1: = dbms_lob.substr(file1,len1,1);
v_xml: = xmltype (UTL_RAW. CAST_TO_VARCHAR2 (v_rec1));

INSERT INTO xml_demo (donnees_xml) VALUES (v_xml);
COMMIT;
DBMS_LOB. FileClose (file1);

exception
while others then
dbms_output.put_LINE (sqlerrm);
DBMS_LOB. FileClose (file1);
END;
/




<? XML version = "1.0" encoding = "UTF-8"? >
< MolDocument DtdVersion = "3" DtdRelease = "0" >
< DocumentIdentification v = "MOL_20100331_1500_1600" / >
< DocumentVersion v = "1" / >
< V DocumentType = "A43" / >
< CodingScheme = v "A01" SenderIdentification = "17X100Z100Z0001H" / >
< SenderRole v = "35" / >
< ReceiverIdentification codingScheme = v "A01" = "10XFR-TEN - Q" / >
< ReceiverRole v = "A04" / >
< CreationDateTime v = "2010-03 - 31 T 14: 10:00Z" / >
< ValidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< codingScheme domain = "A01" v = "10YDOM-1001A001A" / >
< MolTimeSeries >
< ContractIdentification v = "RTE_20100331_1500_16" / >
< ResourceProvider codingScheme = v "A01" = "10XFR-TEN - Q" / >
< CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
< ConnectingArea codingScheme = v "A01" = "10YFR-TEN - C" / >
< AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
< BusinessType v = "10" / >
< BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< MeasureUnitQuantity v = "MAW" / >
< v currency = "EUR" / >
< MeasureUnitPrice v = "MWH" / >
< v direction = "A02" / >
< MinimumActivationQuantity v = "50" / >
< v status = "A06" / >
< period >
< v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< resolution v = "PT60M" / >
<>interval
< v pos = "1" / >
< v Qty = "50" / >
< character v = "50.45" / >
< / interval >
< / period >
< / MolTimeSeries >
< / MolDocument >

Hello

A couple of workarounds, try:

DECLARE

   v_lob   CLOB;
   v_file  BFILE;

BEGIN

   v_file := BFILENAME('XML_DIR','mol.xml');
   DBMS_LOB.createtemporary(v_lob, true);
   DBMS_LOB.fileopen(v_file);
   DBMS_LOB.loadfromfile(v_lob, v_file, DBMS_LOB.getlength(v_file));

   INSERT INTO xml_demo VALUES( xmltype(v_lob) );

   DBMS_LOB.fileclose(v_file);
   DBMS_LOB.freetemporary(v_lob);

END;
/

or,

DECLARE

   v_lob   CLOB;

BEGIN

   v_lob := DBMS_XSLPROCESSOR.read2clob('XML_DIR', 'mol.xml', nls_charset_id('AL32UTF8'));

   INSERT INTO xml_demo VALUES( xmltype(v_lob) );

END;
/

Tags: Database

Similar Questions

  • Insert XML data from the Table-&gt; back to null

    Dear Experts,

    -I have table xml as below:

    Example of CREATE TABLE (XML_spec XMLTYPE);

    Insert in the example
    Select ' < name of Message = "dataStaticInvestor" type = "IncomingMessage" >
    < name of field = "batchReference" > OPENINGBATCH000000 < / field > < List name = "data" >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < / list >
    < / message > ' double.

    Select * example;

    create table hasil1 (c1 varchar2 (500), c2 varchar2 (500), c3 varchar2 (500));

    -This step I create the procedure to insert xml data into the table as the batch.

    DECLARE
    x XmlType;
    BEGIN
    Select XML_SPEC in x for example;

    insert into hasil1
    SELECT
    p.Extract('/Record/Field/@externalReference').getstringval (C1),
    p.Extract('/Record/Field/@participantID').getstringval (C2),
    p.Extract('/Record/Field/@participantName').getstringval () as c3
    TABLE (XMLSequence (Extract(x,'Message/List/Record'))) p;
    commit;
    END;
    /

    -when the result of select hasil1, the output is back 3 rows and 3 columns, but all data is a null *.

    Best regards
    Sigcle

    You don't explain what output you need, but I guess something like this:

    SQL> insert into hasil1 (c1, c2, c3)
      2  select x.c1, x.c2, x.c3
      3  from example t
      4     , xmltable(
      5         'Message/List/Record'
      6         passing t.xml_spec
      7         columns c1 varchar2(500) path 'Field[@name="externalReference"]'
      8               , c2 varchar2(500) path 'Field[@name="participantID"]'
      9               , c3 varchar2(500) path 'Field[@name="participantName"]'
     10       ) x
     11  ;
    
    3 rows inserted
    
    SQL> select * from hasil1;
    
    C1                     C2        C3
    ---------------------- --------- --------------------------------
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
     
    
  • Insert XML data

    I'm trying to insert xml data into the table with the oracle sql developer - sql + it works correctly, but it is very difficult to work with her. How ro resolve this problem?

    Create table credit of XMLType;
     INSERT INTO credit VALUES
    (xmltype(
    ' <?xml version="1.0"?> 
      <creditid>a7565</creditid>'
      ));
    I received the error report:
    SQL error: ORA-31011: failed to parse XML
    ORA-19202: an error has occurred in the processing of XML
    LPX-00209: PI names beginning with XML are reserved
    Error on line 1
    ORA-06512: at "SYS." XMLTYPE", line 310
    ORA-06512: at line 1
    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.


    Thank you.

    Published by: user11974179 on 2012.5.1 14:15

    And in case you do not have access to MOS, just remove the space to the left of the XML string:

    INSERT INTO credit VALUES(
    xmltype('
      a7565')
    );
    
  • Insert in varchar2 select xmltype column: extremely slow

    I use oracle10gR2 10.2.0.4 and solaris10 64bits

    I need to select the data to an xml value in a table of column xmltype (word.testmeta)

    and insert into another table (word.testwordyy)

    desc word.testmeta;
    Name                 Null?    Type
    --------------------------------------
    FILENAME             CHAR(2000)
    XMLDATA              XMLTYPE
    
    
    desc word.testwordyy;
    Name                 Null?    Type
    ---------------------------------------
    ID                   VARCHAR2(255)
    KEYWORD              VARCHAR2(4000)
    

    and I use xmltable

    insert /*+append */ into word.testwordyy(KEYWORD)
    select /*+ gather_plan_statistics */ dbms_lob.substr(xmltype.getclobval(b.KEWOR),254)
    from word.testmeta , xmltable
    (
    '$B/mets/KEWOR'
    passing
    word.testmeta.XMLDATA as B
    columns
    KEWOR xmltype path '/KEWOR/text()'
    )
    b
    

    > select * from table(dbms_xplan.display_cursor(null,null,'iostats last')); 
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  37ua3npnxx8su, child number 0
    -------------------------------------
    insert /*+append */ into word.testwordyy(KEYWORD) select /*+ gather_plan_statistics */
    dbms_lob.substr(xmltype.getclobval(b.KEWOR),254) from word.testmeta , xmltable ( '$B/mets/KEWOR' passing word.testmeta.XMLDATA as
    B columns KEWOR xmltype path '/KEWOR/text()' ) b
    
    
    Plan hash value: 875848213
    
    
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                           | Name                   | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |
    
    
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    |   1 |  LOAD AS SELECT                     |                        |      1 |        |      1 |00:10:32.72 |   16832 |      7 |   90 |
    
    
    |   2 |   NESTED LOOPS                      |                        |      1 |     29M|  34688 |00:00:25.95 |   12639 |      5 |    0 |
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    |   3 |    TABLE ACCESS FULL                | TESTMETA               |      1 |   3638 |   3999 |00:00:00.08 |     909 |      0 |    0 |
    
    
    |   4 |    COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE |   3999 |        |  34688 |00:00:24.50 |   11730 |      5 |    0 |
    
    
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    Note
    -----
       - dynamic sampling used for this statement
    
    
    
    
    21 rows selected.
    

    and the more the number of rows in the word.testmeta table, the more time spent by rank

    I have a small simple XML but I need to process a large amount of them (5000000) as well as the treatment is very very slow when the lines of more than 8000

    Is there an optimization or the fastest?

    Why? Because you do a manipulation of LOB lob.

    Your XMLType is the kind of CLOB storage

    Your chain of subtr quantities are manipulationg LOB

    Altogether, the XML must be done in memory (XMLSEQUENCEFROMXMLTYPE), the manipulation of strings (CLOB) become bigger and bigger and bigger and will eat all your memory and CPU resources.

    How to solve it?

    Upgrade to a supported database version (11.2.0.3 and upwards)

    Store XML documents in a binary XML format of XMLType Securefile

    Use simple methods like XMLCAST to make the string conversion and manipulation

    Or...

    .. m:System.NET.HttpListener.start reading by doing the hard (and today with a version of database not supported), 10.2 through storage XMLType object / relational and convert you CLOB, XMLType storage for storing XMLType object / relational. Use the functions and operators that are created to make the manipulation of strings instead of DBMS_LOB Package (which is not free memory automatically)

  • Loading XML in the XMLTYPE column by separate components (Oracle 11.2.0.4)

    Hi guys,.

    I'm trying to load the file test.xml:

    <? XML version = "1.0"? >

    " < DB-work xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance ">

    < item id = "DB_100" >

    < AddedInLocal > false < / AddedInLocal >

    < AddedInModify > false < / AddedInModify >

    < / point >

    < item id = "DB_101" >

    < AddedInLocal > false < / AddedInLocal >

    < AddedInModify > false < / AddedInModify >

    < / point >

    < item id = "DB_102" >

    < AddedInLocal > false < / AddedInLocal >

    < AddedInModify > true < / AddedInModify >

    < / point >

    < / DB-work >

    in the table:

    CREATE TABLE TEST_XML

    (REQ_NAME, VARCHAR2 (100),)

    XMLTYPE XML_CONTENT

    )

    Intended result in the table:

    REQ_NAME XML_CONTENT
    DB_100

    < item id = "DB_100" >

    < AddedInLocal > false < / AddedInLocal >

    < AddedInModify > false < / AddedInModify >

    < / point >

    DB_101

    < item id = "DB_101" >

    < AddedInLocal > false < / AddedInLocal >

    < AddedInModify > false < / AddedInModify >

    < / point >

    DB_102

    < item id = "DB_102" >

    < AddedInLocal > false < / AddedInLocal >

    < AddedInModify > true < / AddedInModify >

    < / point >

    Load.CTL file wich is full xml load in 1 card:

    load data

    INFILE *.

    BadFile "test.bad."

    discardfile 'test.dsc '.

    Add

    in the test_xml table

    (ext_file filling 40,

    xml_content (ext_file) lobfile completed by expressions of folklore)

    begindata

    test. XML

    Gurus, could you please help me how should I reconfigure load.ctl file to get the desired result?

    Another option would be to insert the data directly, without using SQL * Loader, such as shown below.  This would require that your data file is on your server, not your client.

    Scott@orcl12c > host type c:\my_oracle_files\test.xml

    http://www.w3.org/2001/XMLSchema-instance">

    fake

    fake

    fake

    fake

    fake

    true

    Scott@orcl12c > CREATE TABLE TEST_XML

    2 (REQ_NAME, VARCHAR2 (100),)

    3 XML_CONTENT XMLTYPE

    4     )

    5.

    Table created.

    Scott@orcl12c > create or replace directory mon_repertoire as 'c:\my_oracle_files '.

    2.

    Created directory.

    Scott@orcl12c > insert into test_xml (req_name, xml_content)

    2 select x.id, x.item

    xmltable 3

    4 ("/ DB/work item")

    5 passage xmltype (bfilename ("Mon_repertoire", "test.xml"), NLS_CHARSET_ID ("WE8MSWIN1252'))

    6 columns

    path of varchar2 (100) 7 id "@id."

    path of xmltype 8 point '.') x

    9.

    3 lines were created.

    Scott@orcl12c > column req_name format a8

    Scott@orcl12c > column xml_content format a60

    Scott@orcl12c > select * from test_xml

    2.

    REQ_NAME XML_CONTENT

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

    DB_100

    fake

    fake

    DB_101

    fake

    fake

    DB_102

    fake

    true

    3 selected lines.

  • Error when inserting XML Date in the Table

    Hi all

    I am working on Oracle 11 g and trying to insert a date XML in the table but get error - below

    Query - insert into TableName (ID, CREATION, CREATEDBY) VALUES (50, *'2010 - 12-15 T 12: 57:19'*, 'Name')

    Error - java.sql.SQLDataException: ORA-01861: literal does not match the format string

    CREATED column datatype is Date

    When I try to use sysdate instead of hard-coding XML date of obtaining inserted successfully into the table. Please let me know how to pass this XML format date.

    Thanks in advance.

    Concerning
    Nikhil

    I don't see any XML in what you posted. In any case:

    "2010 12-15 T 12: 57:19'.

    is a string, not a date. Use:

    to_date('2010-12-15T12:57:19','YYYY-mm-dd"T"HH24:mi:SS')

    For example:

    SQL> create table tbl(created date);
    
    Table created.
    
    SQL> insert into tbl values('2010-12-15T12:57:19');
    insert into tbl values('2010-12-15T12:57:19')
                           *
    ERROR at line 1:
    ORA-01861: literal does not match format string
    
    SQL> insert into tbl values(to_date('2010-12-15T12:57:19','YYYY-MM-DD"T"HH24:MI:SS'))
      2  /
    
    1 row created.
    
    SQL> 
    

    SY.

  • Impossible to insert xml data into the table

    HII All,
    I'm unable to parse the following xml file and insert them into the table.


    Version of DB
    ======
    SQL> SELECT *
      2  FROM V$VERSION;
    
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    My DB Table
    Create table rgh_xml_storage
    (
    user_id       varchar2(4000),
    to_type          varchar2(4000),
    mail_id          varchar2(4000),
    subject         varchar2(4000),
    sentDateTime    varchar2(4000)
    )
    Published by: RUSSO April 7, 2011 04:19

    Hello

    Please provide all pertinent details!

    Please correct my insert if statement it must be.

    You have a few bad XPath.
    Here's a way to unnest correctly repeated elements:

    SQL> select x1.user_id,
      2         x1.subject,
      3         x1.sentDateTime,
      4         x2.to_type,
      5         x2.mail_id
      6         --x1.messageBody
      7  from xmltable(
      8    '/emailMessage'
      9    passing xmltype(bfilename('TEST_DIR','email.xml'), nls_charset_id('CHAR_CS'))
     10    columns user_id      varchar2(4000)  path 'headerInformation/sender/user/@userID',
     11            subject      varchar2(4000)  path 'headerInformation/subject',
     12            sentDateTime varchar2(4000)  path 'headerInformation/sentDateTime',
     13            messageBody  clob            path 'messageBody',
     14            my_xml       xmltype         path 'headerInformation/recipients'
     15   ) x1,
     16   xmltable(
     17    '/recipients/recipient'
     18    passing x1.my_xml
     19    columns to_type      varchar2(4000)  path '@type',
     20            mail_id      varchar2(4000)  path 'user/@emailAddress'
     21   ) x2
     22  ;
    
    USER_ID              SUBJECT                                          SENTDATETIME                   TO_TYPE   MAIL_ID
    -------------------- ------------------------------------------------ ------------------------------ --------- ------------------------------------------
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   to        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    
    13 rows selected
     
    
  • Insert XML data into the MySQL database

    Hi all, I'm new with XML and I need help with the insertion of XML data in the mysql database using coldfusion. I looked on the Coldfusion Documentation and saw how to convert XML to a Coldfusion query... but there was no example of how to do an insert. If anyone can give me a good example or point me towards a good direction on how to do it, I would really appreciate it.

    Thank you very much in advance
    Alfie

    Nevermind, I finally managed to do work!

  • inserting XML data in a table

    Hello

    I have a procedure that takes xmltype as input parameter that contains data such as:

    <? XML version = "1.0"? >
    rowset <>
    < ROW >
    < > 7782 EMPNO < / EMPNO >
    CLARK < ENAME > < / ENAME >
    MANAGER < JOB > < / JOB >
    < MGR > 7839 < / MGR >
    < HIREDATE > 9 June 81 < / HIREDATE >
    < SAL > 2450 < / SAL >
    < DEPTNO > 10 < / DEPTNO >
    < / ROW >
    < ROW >
    < > 7839 EMPNO < / EMPNO >
    KING of < ENAME > < / ENAME >
    PRESIDENT < JOB > < / JOB >
    < HIREDATE > 17 November 81 < / HIREDATE >
    < SAL > 5000 < / SAL >
    < DEPTNO > 10 < / DEPTNO >
    < / ROW >
    < ROW >
    < > 7934 EMPNO < / EMPNO >
    MILLER < ENAME > < / ENAME >
    CLERK of < JOB > < / JOB >
    < MGR > 7782 < / MGR >
    < HIREDATE > 23 January 82 < / HIREDATE >
    < SAL > 1300 < / SAL >
    < DEPTNO > 10 < / DEPTNO >
    < / ROW >
    < / LINES >

    I analyze this data and insert into the employee table.
    I remember that using the extract function we can do, but I do not get it exactly.

    Can you please help me in this.

    Thank you
    Vinod

    See [url http://docs.oracle.com/cd/E14072_01/server.112/e10592/functions251.htm#CIHGGHFB] XMLTABLE

    For example:

    -- INSERT INTO 
    
    WITH x AS
    (SELECT XMLTYPE('
    
    
    7782
    CLARK
    MANAGER
    7839
    09-JUN-81
    2450
    10
    
    
    7839
    KING
    PRESIDENT
    17-NOV-81
    5000
    10
    
    
    7934
    MILLER
    CLERK
    7782
    23-JAN-82
    1300
    10
    
    ') myxml
    FROM DUAL)
    SELECT *
    FROM   x
    ,      XMLTABLE('/ROWSET/ROW'
             PASSING x.myxml
             COLUMNS empno, ename, job, mgr, hiredate, sal, deptno); 
    
  • Insert XML data base records

    Hello

    I have a requirement to write a stored procedure that will be an XML file as an input argument and the search for the tags < salary / >, < Manager / > in the XML file and insert those values in a table.

    The pointers will be appreciated.

    Concerning

    Two options are to analyze this in PL/SQL and pass these results in INSERT statements or spending it all in an INSERT

    SELECT... OF... article and let the DB do all the work for you. Without knowing more details, an example of how to do analysis in PL/SQL as an XMLType can be seen in the second method in {: identifier of the thread = 926354}. You would need another loop internal to analyze all OrderDetail nodes because they can repeat for each node in the client.

    If the structure of the table that you ever go in allows it, you can use this as the SELECT part of your INSERT statement

    SQL> SELECT customerid, orderid, productid
      2    FROM XMLTABLE('/ROOT/Customer'
      3                  PASSING XMLTYPE('
      4   
      5   
      6  
      7  
      8  
      9  
     10   
     11   
     12  
     13  
     14  
     15  ')  -- this would just be a variable instead of hard-coded XML
     16                  COLUMNS
     17                  customerid   VARCHAR2(20)  PATH '@CustomerID',
     18                  orderdetails XMLTYPE       PATH 'Order/OrderDetail') ta,
     19         XMLTABLE('/OrderDetail'
     20                  PASSING ta.orderdetails
     21                  COLUMNS
     22                  orderid      VARCHAR2(20)  PATH '@OrderID',
     23                  productid    VARCHAR2(20)  PATH '@ProductID') tb;
    
    CUSTOMERID           ORDERID              PRODUCTID
    -------------------- -------------------- --------------------
    VINET                10248                11
    VINET                10248                42
    LILAS                10283                72
    
  • Insert .xml file into xmltype table?

    Hi experts,

    I'm in I'm in Oracle Enterprise Manager 11 g 11.2.0.1.0.
    SQL * more: Production of release 11.2.0.1.0 killed him Feb 22 11:40:23 2011

    Thank you!

    My an .xml file is listed below:
    <? XML version = "1.0" encoding = "UTF-8"? > <? XML-stylesheet href = "http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type = "text/xsl"? >
    "< document xmlns =" "urn: hl7 - org:v3" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "urn: hl7 - org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" & gt;
    < / value >
    < / observationMedia >
    < / component >
    < / section >
    < / component >
    < / structuredBody >
    < / component >
    < / document >

    Published by: cow on April 4, 2011 12:59

    Published by: cow on April 4, 2011 14:06

    so I can also rely on this DOCUMENT2 to create relational views?

    Yes.

  • How to extract an XML data that have different namespace prefixes?

    Hello

    I have inserted XMLs in an XMLTYPE column which are based on a common XSD that allows different namespaces.

    How can I extract some data from these XMLs using extractvalue when will be preceded different namespaces for this node?

    Thank you and best regards,
    A

    Hello

    You can use XPath:

    //*[local-name()="node_name"]
    

    For example:

    with t as (
     select xmltype(
     '
      mark
      del
     '
     ) doc
     from dual union all
     select xmltype(
     '
      john
      mum
     '
     )
     from dual
    )
    select extractvalue(t.doc,'//*[local-name()="name"]') as name,
           extractvalue(t.doc,'//*[local-name()="place"]') as place
    from t;
    

    or,

    with t as (
     select xmltype(
     '
      mark
      del
     '
     ) doc
     from dual union all
     select xmltype(
     '
      john
      mum
     '
     )
     from dual
    )
    select x.*
    from t, XMLTable(
    '
     {
      element name { //*[local-name()="name"] },
      element place { //*[local-name()="place"] }
     }
     '
    passing t.doc
    columns
     place varchar2(30) path 'place',
     name  varchar2(30) path 'name'
    ) x;
    
  • Query to read the XML of the CLOB column

    Hello

    I want a SQL to get the following information extracted a CLOB column.

    MasterReport/sg:RptDef/sg:RptCell@RealDesc MasterReport/sg:RptDef/sg:RptCell@RealNum
    100 credits
    flow rates from 100

    Example of XML data in the column of table is:
    <? XML version = "1.0" encoding = "UTF-8"? >
    < MasterReport xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:sg = "http://www.oracle.com/fsg/2002-03-20/" xsi: schemaLocation = "http://www.oracle.com/2002-03-20/fsg.xsd" >
    Vision Portugal < sg:LDGName > < / sg:LDGName >
    Vision Portugal < sg:SOBName > < / sg:SOBName >
    Vision Portugal < sg:DataAccessSetName > < / sg:DataAccessSetName >
    Model report 30 < sg:InternalReportName > < / sg:InternalReportName >
    < sg:CustomParam10 / >
    < sg:RowContext RowId = "r100001" >
    < sg:RowName / >
    disputes credits - Total amount previous period < sg:RowLineItem > < / sg:RowLineItem >
    < sg:RowDispUnit > 1 < / sg:RowDispUnit >
    < sg:RowDispFormat / >
    < sg:RowUnitOfMeasure > EUR < / sg:RowUnitOfMeasure >
    < sg:RowLedgerCurrency > ALL < / sg:RowLedgerCurrency >
    < sg:RowCurrencyType > T < / sg:RowCurrencyType >
    < sg:RowChangeSign > 0 < / sg:RowChangeSign >
    < sg:RowSeq > 1.0000000000000 < / sg:RowSeq >
    < / sg:RowContext >
    < sg:RowContext RowId = "r100002" >
    < sg:RowName / >
    < sg:RowLineItem > Litigation credits-taxed amounts of Column2 for the previous period < / sg:RowLineItem >
    < sg:RowDispUnit > 1 < / sg:RowDispUnit >
    < sg:RowDispFormat / >
    < sg:RowUnitOfMeasure > EUR < / sg:RowUnitOfMeasure >
    < sg:RowLedgerCurrency > ALL < / sg:RowLedgerCurrency >
    < sg:RowCurrencyType > T < / sg:RowCurrencyType >
    < sg:RowChangeSign > 0 < / sg:RowChangeSign >
    < sg:RowSeq > 2.0000000000000 < / sg:RowSeq >
    < / sg:RowContext >
    < sg:ColContext ColId = "c1000" >
    < sg:ColAmountType / >
    < sg:ColPeriod / >
    < sg:ColPerOffset / >
    < sg:ColChangeSign / >
    < sg:ColPosition / >
    < sg:ColSeq / >
    < sg:ColWidth > 100 < / sg:ColWidth >
    < / sg:ColContext >
    < sg:ColContext ColId = "c1001" >
    Total of < sg:ColName > < / sg:ColName >
    < sg:ColDescr / >
    < sg:ColDispUnit > 1 < / sg:ColDispUnit >
    < sg:ColUnitOfMeasure > EUR < / sg:ColUnitOfMeasure >
    < sg:ColLedgerCurrency > ALL < / sg:ColLedgerCurrency >
    < sg:ColCurrencyType > T < / sg:ColCurrencyType >
    < sg:ColDispFormat > 999999999.99 < / sg:ColDispFormat >
    CDA-real < sg:ColAmountType > < / sg:ColAmountType >
    < sg:ColPerOffset > 0 < / sg:ColPerOffset >
    < sg:ColAmntId > 14 < / sg:ColAmntId >
    < sg:ColParamId >-1 < / sg:ColParamId >
    A < sg:ColType > < / sg:ColType >
    < sg:ColStyle > B < / sg:ColStyle >
    < sg:ColPeriod > 10 / 08 < / sg:ColPeriod >
    < sg:ColPeriodYear > 2008 < / sg:ColPeriodYear >
    < sg:ColPeriodNum > 11 < / sg:ColPeriodNum >
    < sg:ColPeriodStart > 2008 - 10-01 T 00: 00:00 < / sg:ColPeriodStart >
    < sg:ColPeriodEnd > 2008-10-31 T 00: 00:00 < / sg:ColPeriodEnd >
    < sg:ColChangeSign > 0 < / sg:ColChangeSign >
    the totals of < sg:ColHeadLine1 > < / sg:ColHeadLine1 >
    < sg:ColHeadLine2 / >
    < sg:ColHeadLine3 / >
    < sg:ColHeadLine4 / >
    < sg:ColHeadLine5 / >
    < sg:ColHeadLine6 / >
    < sg:ColHeadLine7 / >
    < sg:ColHeadLine8 / >
    < sg:ColHeadLine9 / >
    < sg:ColPosition > 99 < / sg:ColPosition >
    < sg:ColSeq > 1.0000000000000 < / sg:ColSeq >
    < sg:ColWidth > 14 < / sg:ColWidth >
    < / sg:ColContext >
    "< sg:RptDef RptId = 'p1001" RptDetName = "book = PT Vision (Vision Portugal)" RptPESegm = "" RptPEVal = "" RptTabLabel = "Exit 1 (Vision PT)" > "
    < sg:RptLine RptCnt = 'p1001"RowCnt ="r100001"LineRowSeq ="1.0000000000000"LinCnt ="l100001">
    < sg:RptCell ColCnt RealDesc "c1000" = "flows" = > flow < / sg:RptCell >
    < sg:RptCell ColCnt "c1001' RealNum = '100.000000' = > 100,00 < / sg:RptCell >
    < / sg:RptLine >
    < sg:RptLine RptCnt = 'p1001"RowCnt ="r100002"LineRowSeq ="2.0000000000000"LinCnt ="l100002">
    < sg:RptCell ColCnt = "c1000" RealDesc = "creditsd" > credits < / sg:RptCell >
    < sg:RptCell ColCnt "c1001' RealNum = '100.000000' = > 100,00 < / sg:RptCell >
    < / sg:RptLine >
    < / sg:RptDef >
    < sg:TabCount > 1 < / sg:TabCount >
    < / MasterReport >

    Please help me.

    Concerning
    Goussard

    Published by: user576087 on March 18, 2012 23:54

    I don't know if you want that the values of the attribute or the element, but it should give you a good start:

    SQL> alter session set nls_numeric_characters = ".,";
    
    Session altered
    
    SQL>
    SQL> select x.*
      2  from my_table t
      3     , xmltable(
      4         xmlnamespaces('http://www.oracle.com/fsg/2002-03-20/' as "sg")
      5       , '/MasterReport/sg:RptDef/sg:RptLine'
      6         passing xmltype(t.xmldoc)
      7         columns type    varchar2(30) path 'sg:RptCell[1]'
      8               , amount  number       path 'sg:RptCell[2]'
      9       ) x
     10  ;
    
    TYPE                               AMOUNT
    ------------------------------ ----------
    debits                                100
    credits                               100
     
    
  • Help - query on the XMLType column?

    Hello

    Please could someone help me to write a query to extract data from XMLType column in the script below:

    Here is my example of WHAT XML stored in the XMLType column:
     <?xml version="1.0" encoding="UTF-8"?>
    <cf:IncidentReportGroup xmlns:cf="http://xml.crossflo.com/jxdm/3.0.3"
    xmlns:j="http://www.it.ojp.gov/jxdm/3.0.3" xmlns:ext="http://xml.crossflo.com/jxdm/3.0.3/extension"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:i="http://www.it.ojp.gov/jxdm/appinfo/1">
        <cf:IncidentReport>
            <ext:Incident>
                <j:ActivityID>
                    <j:ID>99999999999999</j:ID>
                </j:ActivityID>
                <j:ActivityDate>2007-01-13</j:ActivityDate>
                <j:ActivityTime>01:25:00Z</j:ActivityTime>
            </ext:Incident>
        </cf:IncidentReport>
    </cf:IncidentReportGroup>
    I want to retrieve ActivityDate and ActivityTime where ActivityID/ID = 'something'...

    Here is the example query I wrote but no luck:
    SELECT extractValue(xml_doc, '/cf:IncidentReport/ext:Incident/j:ActivityDate','/cf:IncidentReport/ext:Incident/j:ActivityTime')
      FROM TABLEA 
      where existsNode(xml_doc,'/cf:IncidentReport/ext:Incident/j:ActivityID[j:ID="99999999999999"]')
     
    SQL>  var ID varchar2(20)
    
    SQL>  exec :ID := '99999999999999'
    PL/SQL procedure successfully completed.
    
    SQL>  with t as (
     select xmltype('
    
        
            
                
                    99999999999999
                
                2007-01-13
                01:25:00Z
            
        
    ') xml from dual
    )
    select t2.*
      from t t, xmltable(xmlnamespaces('http://xml.crossflo.com/jxdm/3.0.3/extension' as "ext",
                                       'http://www.it.ojp.gov/jxdm/3.0.3' as "j"),
                         'ext:Incident[j:ActivityID/j:ID=$ID]'
                         passing t.xml.extract('//ext:Incident','xmlns:ext="http://xml.crossflo.com/jxdm/3.0.3/extension"'),
                                 xmlelement(ID, :ID) as ID
                         columns ActivityID   varchar2(10) path 'j:ActivityID',
                                 ActivityDate varchar2(10) path 'j:ActivityDate',
                                 ActivityTime varchar2(10) path 'j:ActivityTime') t2
    /
    ACTIVITYID ACTIVITYDA ACTIVITYTI
    ---------- ---------- ----------
    9999999999 2007-01-13 01:25:00Z
    1 row selected.
    

    Published by: michaels2 on March 2, 2009 08:43

  • Manipulate xml data

    From an XML file, I can retrieve the content and display it in a single column. This part works perfectly!

    But when it comes to separate my xml data in 2 columns... no luck.
    Can someone guide me and split my articles in a new line when 10 items are met?


    Hi blow
    It's here: GET HERE
    I changed a part of each function at the bottom. Then change tehm all. Just the ones from downstairs. I also change the function of "makeSubMenu" at the top of your code. In this function, the parameters is now "node" and no more "node.childNodes. Long to explain, but it works perfectly now. When I change the code before that I didn't think that wiil you need for the type of menu. This is the reson why I need to keep the knot all not only the node.childNodes. Well well down, here's what I did:
    1 - in the 'attachSubMenuItem' is a button for each clip id. Use of subment which now have been clicked
    2 - I always use the same if the "setSubmenuEvents" function is the only event in. It's a good way to work in the case that you want to add other celebrations.
    3 - I had to change a bit of your code in the "levelTwoEmpty ["item"+ i] .onRelease" now called as "clickEventSub". Not only an event, but a function. Code inside has been change to work with the new code. Also, I use the case of the switch instead of the otherwise if if else etc. In this case, it

    Hope that can help.

Maybe you are looking for