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')
);

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

  • 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); 
    
  • 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
     
    
  • 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;
    /
    
  • 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
    
  • Error occurred when the XML data is inserted in the table.

    Hello

    I'm trying to load the xml data into the table of following code.but get below error

    Error on line 1
    ORA-31011: XML parsing failed
    ORA-19202: an error has occurred in the processing of XML
    LPX-00222: error received from the SAX callback function
    ORA-06512: at "SYS." DBMS_XMLSTORE', line 78
    ORA-06512: at line 21

    DECLARE
     
      xmldoc   clob;
      insCtx   DBMS_XMLStore.ctxType;
      dname    varchar2(20) := 'MDIR';
      rows  number;
     
     BEGIN
     
        xmldoc := dbms_xslprocessor.read2clob(dname, 'try_xm3.xml');
        insCtx := DBMS_XMLStore.newContext('try1');
     dbms_output.put_line('1');
        DBMS_XMLStore.setRowTag(insCtx, 'cajas');
     rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
     
     commit;
      dbms_output.put_line('INSERT DONE '||TO_CHAR(rows));
     
      DBMS_XMLStore.closeContext(insCtx);
     
     END;
    <?xml version="1.0" encoding="utf-8"?>
    <cajas xmlns="PBcion.Caja" fec="2011-03-02T14:20:14" codDeleg="093">
      <caj codPrev="80001223" fechaInicio="2011-03-02" fec="2011-09-02" couta="01" idPerio="1" caj="32"></caj>
     </cajas>
    can you please look at this?
    I m using oracle 10g
    insert
      into try1
      with t as (
                 select xmltype('') x from dual
                )
      select  codPrev,
              fechaInicio,
              fec,
              couta,
              idPerio,
              caj
        from  t,
              xmltable(
                       '/'
                       passing x
                       columns
                         codPrev number path '@codPrev',
                         fechaInicio varchar2(25) path '@fechaInicio',
                         fec varchar2(25) path '@fec',
                         couta number path '@couta',
                         idPerio number path '@idPerio',
                         caj number path '@caj'
                      )
    /
    
    1 row created.
    
    SQL>  select  *
      2    from  try1
      3  /
    
       CODPREV FECHAINICIO               FEC                            COUTA    IDPERIO        CAJ
    ---------- ------------------------- ------------------------- ---------- ---------- ----------
      80001223 2011-03-02                2011-09-02                         1          1         32
    
    SQL> 
    

    SY.

  • Extraction of XML data

    Hello

    I have a requirement to extract data from XML and insert in a custom table.

    XML structure is

    < A >

    < Column1 >

    < Column2 >

    < Column3 >

    < Column4 >

    < column > 5

    < A >

    < A1 >

    < Column1 >

    < Column2 >

    < Column3 >

    < Column4 >

    < column > 5

    < A1 >

    .

    .

    .

    .

    < a >

    < Column1 >

    < Column2 >

    < Column3 >

    < Column4 >

    < column > 5

    < a >


    I need to extract all the values in the column and insert it into a custom table.

    Number of nodes one will increase every day, and columns can be of the order of 50-100.


    With the help of EXTRACTVALUE and bulk collect I m doing this process, but taking almost 2 hours for the processing of 3000 records.


    Please let me know is there better way (in terms of performance) to extract XML data?


    Thank you

    Kumar.

    Why the node is called as A1, A2... One? Why can it not be Just A? Here's an example of how to represent XML report and analyzed data to a relational structure.

    SQL> with t
      2  as
      3  (
      4  select xmltype
      5         (
      6  '
      7      
      8           1
      9           ram
     10           01-01-2016
     11           10000
     12      
     13      
     14           2
     15           karthick
     16           01-01-2016
     17           10000
     18      
     19      
     20           3
     21           subha
     22           01-01-2016
     23           10000
     24      
     25      
     26           4
     27           vimal
     28           01-01-2016
     29           10000
     30      
     31      
     32           5
     33           vijay
     34           01-01-2016
     35           10000
     36      
     37  
    ' 38 ) xmldata 39 from dual 40 ) 41 select t1.* 42 from t 43 , xmltable 44 ( 45 '/table/row' passing xmldata 46 columns 47 empno number path 'empno', 48 ename varchar2(10) path 'ename', 49 doj varchar2(10) path 'doj', 50 sal number path 'sal' 51 ) t1; EMPNO ENAME DOJ SAL ---------- ---------- ---------- ---------- 1 ram 01-01-2016 10000 2 karthick 01-01-2016 10000 3 subha 01-01-2016 10000 4 vimal 01-01-2016 10000 5 vijay 01-01-2016 10000
  • Select the XML data

    Dear all,

    Please find a list of the steps done to read the date of conversion of currency by the last final query, that I can be able to obtain the release of the name of the Bank as the Central Bank, but impossible to extract the time, rates, currency of the XML data.

    Please tell us how to solve the problem.

    CREATE TABLE url_tab

    (

    URL_NAME VARCHAR2 (100),

    SYS URL. URIType

    );

    INSERT INTO url_tab VALUES

    ("This is a test URL',

    sys . UriFactory.getUri ("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml" "")

    );

    INSERT into xml_data_tab select sys.xmltype.createXML (u.url.getClob ()) in u url_tab;

    Select Bank_name, xt1.* from

    XMLTable (XMLNamespaces (default 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref', ))

                                   ' ( http://www.GESMES.org/XML/2002-08-01 ' as "gesmes"),

    ' / / gesmes:Envelope'

    FROM (select * from xml_data_tab)

    columns

    Path of varchar2 (100) Bank_name ' / gesmes:Envelope / gesmes:Sender / gesmes:name',

    outer join left perv_t XMLTYPE PATH "Cube/Cube")

    XMLTable (XMLNamespaces ('http://www.gesmes.org/xml/2002-08-01' as "gesmes"), )

    "/ / Cube/Cube."

    FROM (select * from xml_data_tab)

    COLUMNS

    path of varchar2 (100) of rate_date "@time"

    path varchar2 (100) coin "@currency."

    path of rate varchar2 (100) '@rate') xt1 on 1 = 1

    its work for me

    SQL > with xml_data_tab like)

    2. Select XMLType)

    3'http://www.gesmes.org/xml/2002-08-01' xmlns ="http://www.ecb.int/vocabulary/2002-08-01/eurofxref" >. "

    4 reference rate

    5

    6 the European Central Bank

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    38

    39

    40

    41

    42

    43 ') as the double DATA

    44)

    45 select Bank_name, xt1. RATE_DATE, xt2.*

    XMLTable 46 (XMLNamespaces (default 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref',

    47'http://www.gesmes.org/xml/2002-08-01"as"gesmes"),"

    48 ' / / gesmes:Envelope'

    49 FROM (select * from xml_data_tab)

    50 columns

    51 way of varchar2 (100) of Bank_name ' / gesmes:Envelope / gesmes:Sender / gesmes:name',

    52 perv_t XMLTYPE PATH 'Cube'):

    53 left outer join XMLTable (XMLNamespaces (default 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref'),

    54                         '*'

    55 in PASSING (h.perv_t)

    56 COLUMNS

    path of varchar2 (100) 57 rate_date "Cube/@time."

    58 rate_data XMLType path ' / / Cube/Cube ') xt1 on 1 = 1

    59 left outer join XMLTable (XMLNamespaces (default 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref'),

    60 ' / / cube/Cube/Cube. "

    61 FROM (select * from xml_data_tab)

    62 COLUMNS

    path of VARCHAR2 (3) currency 63 "@currency."

    number 64 path "@rate" rate) xt2 on 1 = 1;

    BANK_NAME RATE_DATE HEART RATE

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

    2015 Central Bank European-12-30 US $ 1.0926

    30-12-2015 of the European Central Bank JPY 131.66

    2015 Central Bank European-12-30 BGN 1.9558

    2015 Central Bank European-12-30 CZK 27.029

    30-12-2015 of the European Central Bank DKK 7.4625

    2015 Central Bank European-12-30 GBP.73799

    30-12-2015 of the European Central Bank HUF 313,15

    2015 Central Bank European-12-30 PLN 4.24

    30-12-2015 of the European Central Bank, RON 4.5296

    2015 Central Bank European-12-30 SEK 9.1878

    2015 Central Bank European-12-30 CHF 1.0814

    BANK_NAME RATE_DATE HEART RATE

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

    2015 Central Bank European-12-30 NOK 9.616

    30-12-2015 of the European Central Bank 7.637 HRK

    30-12-2015 of the European Central Bank RUB 79.754

    30-12-2015 of the European Central Bank TRY 3.1837

    2015 Central Bank European-12-30 AUD 1.499

    30-12-2015 of the European Central Bank BRL 4.259

    2015 Central Bank European-12-30 CAD 1.5171

    2015 Central Bank European-12-30 CNY 7.091

    2015 Central Bank European-12-30 HKD 8.4685

    30-12-2015 of the European Central Bank IDR 15081.33

    30-12-2015 of the European Central Bank, ILS 4.2606

    BANK_NAME RATE_DATE HEART RATE

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

    30-12-2015 of the European Central Bank INR 72.535

    30-12-2015 of the European Central Bank 1284.79 KRW

    2015 Central Bank European-12-30. 18.8867 MXN

    30-12-2015 of the European Central Bank MYR 4.6887

    2015 Central Bank European-12-30 NZD 1.5959

    30-12-2015 of the European Central Bank PHP 51.281

    30-12-2015 of the European Central Bank SGD 1.5449

    2015 Central Bank European-12-30 THB 39.334

    30-12-2015 of the European Central Bank ZAR 16.8847

    31 selected lines.

  • extract data from blob field containing xml data big

    I'm working on Oracle 11 g 2, 11.0.2.0.3. UNIX database server.

    my oracle instance receive large xml data service web ftp, I put this file as blob in a table called TBL_ALERT_XML (ID_ALERT NUMBER, DATE of the TIMESTAMP_ALERT, ALERT_XML BLOB).

    My goal is to get data of BLOB content e file put in one or more other tables.

    I try with the opening of a cursor on

    SELECT XMLTYPE (UTL_RAW.cast_to_varchar2 (ALERT_XML)). Extract (' alerts/points/point / / Text () ') threads

    OF TBL_ALERT_XML

    without any filter on ID_ALERT.

    But I get the error:

    ORA-22835: buffer too small for to CHAR CLOB or BLOB to RAW conversion



    Please help me, thank you very much

    Because the web service is deployed in python and my co worker is not able to call a stored procedure with the parameter xmltype, but only with the setting of the BLOB.

    If you can't get around it, so be it. All the less, using CLOB would be better.

    However, which prevents you to convert BLOB XMLType entry within the stored procedure and store it in an XMLType column.

    To do this, simply use the XMLType of BLOB.

    create table tbl_alert_xml)

    number of id_alert

    date of timestamp_alert

    alert_xml xmltype

    );

    insert into tbl_alert_xml

    values)

    1

    sysdate

    xmltype (p_blob

    , nls_charset_id ('AL32UTF8') - put the encoding of the file here

    )

    );

    Then, you will be able to execute queries optimized using XMLTABLE.

  • How to import xml data from a site http with PL/SQL

    Hello

    I created a table with an XML field as follows:

    1 save the scheme "service."

    2. create table 'command.

    3 imported data in the table 'Command' of string data.

    Everything works perfectly fine, but I need insert the data directly from a URL like this

    http://API.mercadopublico.CL/Servicios/v1/Publico/ordenesdecompra.XML?Fecha=02022014 & ticket = F8537A18-6766-4def-9E59-426B4FEE2844

    attached I include codes

    Please can you help me with the solution.


    Thank you very much

    Hi Carlos,

    You can use HTTPURITYPE to access the resource by its url:

    insert into Ordenes values (
      1
    , httpuritype('http://api.mercadopublico.cl/servicios/v1/publico/ordenesdecompra.xml?fecha=02022014&ticket=F8537A18-6766-4DEF-9E59-426B4FEE2844').getxml()
    );
    

    If you're on 11g, you may also need to set an ACL for the request.

  • Update of a column of table from xml data

    Hello

    I have an obligation to update a particular table from xml data column. to do this, I wrote the code below but I am not able to insert. could you please a peek into that.

    create table emp3
    as
    select *From emp
    where 1=1;
    
    alter table emp3
    add (fax_response varchar2(50));
    
    /*create sequence EmailRecords_XMLFILE_SEQ
      minvalue 1
      maxvalue 999999999999999999999999999
      start with 1
      increment by 1
      nocache;*/
    
    /* create global temporary table EmailRecords_XMLFILE
      (
      ID NUMBER not null,
      xmlfile CLOB
      )
      on commit preserve rows;*/
    
    /* create global temporary table UPD_Email_Records_With_Xml
      (
      id NUMBER not null,
    
      response VARCHAR2(500)
    
      )
      on commit preserve rows; */
    
    
    

    the XML data is

    <FAX>
    <EMAILOG>
    <ID>7839</ID>
    <RESPONSE>FAX SENT</RESPONSE>
    </EMAILOG>
    <EMAILOG>
    <ID>7566</ID>
    <RESPONSE>FAX NOT SENT</RESPONSE>
    </EMAILOG>
    </FAX>
    
    
    

    CREATE OR REPLACE PROCEDURE proc_upd_email_records (
       loc_xml          IN       CLOB,
       p_err_code_out   OUT      NUMBER,
       p_err_mesg_out   OUT      VARCHAR2
    )
    IS
       loc_id   NUMBER;
    BEGIN
       loc_id := emailrecords_xmlfile_seq.NEXTVAL; --created sequence
    
    
    
       INSERT INTO emailrecords_xmlfile --created Global Temp table
                   (ID, xmlfile
                   )
            VALUES (loc_id, loc_xml
                   );
    
       COMMIT;
          insert into UPD_Email_Records_With_Xml --created Global Temp table
            (ID, RESPONSE)
            select x1.id,
    
                      x1.RESPONSE
              from EmailRecords_XMLFILE,
                   xmltable('/FAX/EMAILOGID' passing
                            xmltype.createxml(EmailRecords_XMLFILE.xmlfile)
                            columns header_no for ordinality,
                            id number path 'ID',
                            RESPONSE VARCHAR2(250) path 'RESPONSE'
    
                               ) x1
             where EmailRecords_XMLFILE.id = loc_id;
       COMMIT;
    
       UPDATE emp3 er
          SET er.fax_response = (SELECT response
                               FROM upd_email_records_with_xml pr
                              WHERE pr.ID = er.empno)
        WHERE er.empno IN (SELECT ID
                             FROM upd_email_records_with_xml);
    EXCEPTION
       WHEN NO_DATA_FOUND
       THEN
          raise_application_error
             (-20000,
              'Sorry ! The Xml File which is passed is empty. Please try with Valid Xml File. Thank you!!! '
             );
       WHEN OTHERS
       THEN
          p_err_code_out := 4;
          p_err_mesg_out := 'error in insertion=> ' || SQLERRM;
    END proc_upd_email_records;
    {code}{code}
    
    
    

    Someone suggest me a slightly easier way to insert data...

    Thank you...

    You're complicating things

    A simple MERGE statement will do.

    create or replace procedure (proc_upd_email_records)

    loc_xml in clob

    )

    is

    Start

    merge into e emp3

    a_l'_aide_de)

    Select id

    response

    from xmltable)

    "/ FAX/EMAILOG.

    by the way xmlparse (document loc_xml)

    the columns id number way "ID".

    , path of varchar2 (250) response 'RESPONSE '.

    )

    ) v

    on (e.empno = v.id)

    When matched then update

    Set e.fax_response = v.response

    ;

    end;

    /

    But there is no value added by using these temporary tables if you are not at least an intermediate XMLType column (storage preferably binary XML).

    -What is the input XML code?

    -What is the version of db?

  • Store XML data in tables

    Hello

    I must write a procedure which takes the XML data and inserts in some tables.

    If the XML format is fixed so I can use the extract for analysis and can insert in the tables.

    But the problem is not fixed the XML format.

    Y at - it no integrated package that supports the xml for analysis data...

    Can you please suggest me in this case.

    Thank you
    Vinod

    >

    Hi vinod,

    I must write a procedure which takes the XML data and inserts in some tables.
    If the XML format is fixed so I can use the extract for analysis and can insert in the tables.
    But the problem is not fixed the XML format.
    Y at - it no integrated package that supports the xml for analysis data...

    You will have to do a little reading. I would recommend that you start here
    http://docs.Oracle.com/CD/B10500_01/AppDev.920/a96621/adx20ppl.htm (if all else fails, read the docco!  ;))
    http://www.Oracle-base.com/articles/9i/parse-XML-documents-9i.php
    http://www.quovera.com/whitepapers/downloads/xml_oracle.PDF
    http://anononxml.blogspot.IE/2010/12/methods-to-parse-XML-per-Oracle-version.html
    http://www.orafaq.com/wiki/XML

    orafaq and oracle-base are good global Oracle sites.

    You can also look at [url http://forums.oracle.com/forums/forum.jspa?forumID=34] here - the XML DB forum.

    HTH,

    Paul...

    Vinod

Maybe you are looking for