How to read XML in blob field

Hi guys,.

Small need advise on your part.

My requirement is to read the XML file, which is stored as a BLOB in a table through plsql code.

Basically, I need to get the attribute values in the XML through code.



See you soon

Sexy

And once you have the data as XMLTYPE data type like Johan said, you can retrieve the data by using the function XMLTABLE...

for example

WITH t as (select XMLTYPE('

  
    1
    1800
    
      1
      28
      6
      12
    
    
      5
      19
      1
      90
    
  
  
    2
    2400
    
      3
      14
      7
      5
    
  
') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task
from t
    ,XMLTABLE('/RECSET/REC'
              PASSING t.xml
              COLUMNS country NUMBER PATH '/REC/COUNTRY'
                     ,point   NUMBER PATH '/REC/POINT'
                     ,user_info XMLTYPE PATH '/REC/*'
             ) x
    ,XMLTABLE('/USER_INFO'
              PASSING x.user_info
              COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
                     ,target  NUMBER PATH '/USER_INFO/TARGET'
                     ,state   NUMBER PATH '/USER_INFO/STATE'
                     ,task    NUMBER PATH '/USER_INFO/TASK'
             ) y

   COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
---------- ---------- ---------- ---------- ---------- ----------
         1       1800          1         28          6         12
         1       1800          5         19          1         90
         2       2400          3         14          7          5

Tags: Database

Similar Questions

  • XML in BLOB field.

    Hi Experts,

    ORACLE 10G

    My table structure as below the BLOB column with XML file

    Lobid number (10)
    File_Blob Blob () - with the XML from the file

    My requirement is to analyze the XML Blob of code put in dish/text file with separators now java code did this and take more time
    How to optimize it.

    Thank you very much
    Kalinga

    I'm not sure what you want to use 'any delimiter' and you have not specified your needs analyzing. The following will unload the blob to a file on the operating system.

    You can conver the blob xml as shown below and we many sql/plsql to work on the XML and then functions that write to a file.

    the write_blob_to_file methods are a copy of what I have in my custom util plsql package

    I hope this helps.

    Mark Wooldridge
    Secure Solutions, Inc. database.

    declare
    
    v     blob;
    x     xmltype;
    
    procedure write_blob_to_file(p_blob                    in blob,
                                 p_file                    in utl_file.file_type) is
    
    v_buffer     raw(32767);
    v_buffer_size     constant binary_integer := 8191;
    v_amount     binary_integer;
    v_offset     number;
    v_size          number;
    
    begin
     if p_blob is null or dbms_lob.getlength(p_blob) = 0
      then return;
     end if;
    
     v_size          := dbms_lob.getlength(p_blob);
     v_amount     := v_buffer_size;
     v_offset     := 1;
    
    -- dbms_output.put_line('length: '||v_size);
    
     while v_amount >= v_buffer_size and v_offset <= v_size
     loop
      dbms_lob.read(lob_loc     => p_blob,
                    amount     => v_amount,
                    offset     => v_offset,
                    buffer     => v_buffer);
    
      v_offset := v_offset + v_amount;
    
      utl_file.put_raw(file          => p_file,
                       buffer     => v_buffer,
                       autoflush     => true);
    
     end loop;
    
    end write_blob_to_file;
    
    procedure write_blob_to_file(p_blob                    in blob,
                                 p_directory               in varchar2,
                                 p_file_name               in varchar2,
                                 p_write_null_file               in boolean     default true) is
    
    c_line_size     constant number := 32767;
    v_file_handle     utl_file.file_type;
    
    begin
    -- dbms_output.put_line('blob_to_file -dir: '||p_directory||' - file: '||p_file_name||' - size: '||dbms_lob.getlength(p_blob));
    
     if not p_write_null_file and p_blob is null
      then return;
     end if;
    
     v_file_handle := utl_file.fopen(location     => p_directory,
                                     filename     => p_file_name,
                                     open_mode     => 'wb',
                                     max_linesize     => c_line_size);
    
     write_blob_to_file(p_blob, v_file_handle);
    
     utl_file.fclose(file => v_file_handle);
    
    end write_blob_to_file;
    
    begin
     /**
      * create example xml as a blob
      *
      * 873 is the character set id for NLS_CHARACTERSET  AL32UTF8
      * select *
      *   from v$nls_parameters
      *
      * select nls_charset_id('AL32UTF8')
      *   from dual
      *
      */
     select xmltype('fac1').getblobval(873)
       into v
       from dual;
    
     --* this was just a test to conver the blob to an xmltye
     x := xmltype(v, 873);
    
     write_blob_to_file(v, 'DEBUGDIR', 'msw.xml');
    
    end;
    /
    
  • How to read pdf form data/fields

    Hello

    I want to orchestrate a process where the entrance is formed interactive and is the xml data output.

    I mean that I want to read/data fields of the pdf form.

    What activity are used on bench.

    Concerning

    Sunil

    Try the ExportData or ProcessFormSubmission service.

    I hope that helps!

    Vikas - Vijayrania

  • How to read XML data stored as a Clob

    Hello
    I'm new on clob & XML types...
    Data XML has been inserted into a Clob field in a Table in Oracle (9.2.0.8.0)
    -----------------------------------------------------------
    CREATE THE TEMP TABLE
    (
    SNO NUMBER (5),
    STR_VAL LONG,
    CREATED_DT DATE default sysdate,
    COL2 CLOB,
    COL3 SYS. XMLTYPE
    )
    -----------------------------------------------------------
    SELECT dbms_lob.getlength (col2) of temp
    ---
    -> 24754
    -----------------------------------------------------------
    SQL > select temp col2;

    COL2
    ----------------------------------------------
    & lt; DataSet1 & gt;
    & lt; TAGSDATATABLE & gt;
    & lt; TAG_NAME & gt; KST20001 & lt; / TAG_NA
    --------------------------------------------------------------------------
    If I use the stmt above it shows only a pice of data


    How can I get the data in this column.

    could someone help to obtain the data.

    Concerning
    Prakash

    Published by: user12957183 on August 25, 2010 12:25 AM

    Insert data in to table XMLTYPE clob variable:

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2  my_clob CLOB := 'KST20001
      3  KST20002
      4  KST20003
      5  
      6  KST20004
      7  
      8  
      9  KST20005
     10  
     11  
     12  KST20006
     13  
     14  
     15  KST20007
     16  
     17  
     18  KST20008
     19  
     20  
     21  KST20009
     22  
     23  
     24  KST20010
     25  
     26  
     27  KST20009
     28  
     29  ';
     31  BEGIN
     33  INSERT INTO my_tab1 VALUES(XMLTYPE(my_clob));
     34* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
    SQL> desc my_tab1;
     Name
     ---------------------------------------------------------------------------------------------------
     TABLE of XMLTYPE
    
    SQL> 
    
    -- For larger data:
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2  my_clob CLOB := '
      3  
      4  KST20001
      5  
      6  
      7  KST20002
      8  
      9  
     10  KST20003
     11  
     12  
     13  KST20004
     14  
     15  
     16  KST20005
     17  
     18  
     19  KST20006
     20  
     21  
     22  KST20007
     23  
     24  
     25  KST20008
     26  
     27  
     28  KST20009
     29  
     30  
     31  KST20010
     32  
     33  
     34  KST20009
     35  
     36  
     37  KST20009
     38  
     39  
     40  KST20009
     41  
     42  
     43  KST20009
     44  
     45  
     46  KST20010
     47  
     48  
     49  KST20009
     50  
     51  
     52  KST20009
     53  
     54  
     55  KST20009
     56  
     57  
     58  KST20009
     59  
     60  
     61  KST20010
     62  
     63  
     64  KST20009
     65  
     66  
     67  KST20009
     68  
     69  
     70  KST20009
     71  
     72  
     73  KST20009
     74  
     75  
     76  KST20010
     77  
     78  
     79  KST20009
     80  
     81  
     82  KST20009
     83  
     84  
     85  KST20009
     86  
     87  
     88  KST20009
     89  
     90  
     91  KST20010
     92  
     93  
     94  KST20009
     95  
     96  
     97  KST20009
     98  
     99  
    100  KST20009
    101  
    102  
    103  KST20009
    104  
    105  
    106  KST20010
    107  
    108  
    109  KST20009
    110  
    111  
    112  KST20009
    113  
    114  
    115  KST20009
    116  
    117  
    118  KST20009
    119  
    120  
    121  KST20010
    122  
    123  
    124  KST20009
    125  
    126  
    127  KST20009
    128  
    129  
    130  KST20009
    131  
    132  
    133  KST20009
    134  
    135  
    136  KST20010
    137  
    138  
    139  KST20009
    140  
    141  
    142  KST20009
    143  
    144  
    145  KST20009
    146  
    147  ';
    148  l_xmltype xmltype;
    149  BEGIN
    150  --l_xmltype := my_clob;
    151  INSERT INTO my_tab1 VALUES(XMLTYPE(my_clob));
    152* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    Published by: AP on August 25, 2010 04:46

  • How to read XML file in InDesign Script

    indesign #target

    var myFile is File.openDialog ("file select XML");.

    If (myFile! = null)

    { myFile.open("r");

    myElement var = new XML (myFile.read ());

    myFile.close ();

    Alert (MyElement.xmlElements.Length);

    }

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

    Code above does not have XML elements, variable myElement to get all the data to an xml file,

    but I don't get her child of the elements...

    Can someone help me solve this problem please...

    Thank you...

    Hello

    Try this...

    alert(myElement.elements().length());
    

    Concerning

  • How to READ XML and display hirarechy and data in separate columns 2

    Hi, I have the following XML example and I need to extract the hirarechy and values separately. If the value is null, hirarechy must be displayed. Please advice!
    for example,.
    I want to output something this link

    NŒUD
    ---------------------------
    8. TEST4. FIVE
    8. TEST4. SIX
    8. TEST4. 7. TEST2. TWO
    8. TEST4. 7. TEST2. THREE



    VALUE
    ------------------------------------
    1

    5
    I test m


    example of XML data:

    <? XML version = "1.0"? >
    rowset <>
    < ROW >
    < 8 >
    < TEST4 >
    < 5 > 1 < / FIVE >
    < 6 / >
    < 7 >
    < TEST2 >
    < TWO > 5 < / TWO >
    test of m i < 3 > < / 3 >
    < 4 >
    < A > 26 March 12 < / ONE >
    < / OVEN >
    < / TEST2 >
    < / SEVEN >
    < / TEST4 >
    < TEST4 >
    < 5 > 1 < / FIVE >
    < SIX > 26 March 12 < / SIX >
    < 7 >
    < TEST2 >
    < TWO > 5 < / TWO >
    < 3 > 67 < / 3 >
    < 4 >
    < A > 26 March 12 < / ONE >
    < / OVEN >
    < / TEST2 >
    < / SEVEN >
    < / TEST4 >
    < / 8 >
    < / ROW >
    < / LINES >

    Thank you

    Published by: Saad at March 26, 2012 15:18

    What is xml_test in your example? his error on this one.

    This is a table of xmltype object I used to store your XML for my first tests.
    Sorry, I forgot to remove the part while testing with a variable binding in place.

    Try this one (pass your real xmltype variable instead of xmltype(:xmldoc)):)

    SELECT x.node_id
         , x.node_value
    FROM XMLTable(
         'declare function local:getChildren($e as node(), $pID as xs:string?) as element()*
          {
            for $i in $e/(child::*|attribute::*)
            let $ID := if ($pID) then concat($pID,".",name($i)) else name($i)
            return element r
            {
              attribute is_leaf {empty($i/child::*)}
            , element node_id {$ID}
            , element parent_node_id {$pID}
            , element node_name {name($i)}
            , if ($i instance of attribute())
                then ( element node_value {data($i)}, element node_kind {"attribute"} )
                else ( element node_value {$i/text()}, element node_kind {"element"} )
            }
            | local:getChildren($i,$ID)
          }; (: :)
          local:getChildren($d/ROWSET/ROW,())'
          passing xmltype(:xmldoc) as "d"
          columns node_id         varchar2(100)   path 'node_id'
                , node_name       varchar2(30)    path 'node_name'
                , node_value      varchar2(2000)  path 'node_value'
                , parent_node_id  varchar2(100)   path 'parent_node_id'
                , node_kind       varchar2(30)    path 'node_kind'
                , is_leaf         varchar2(5)     path '@is_leaf'
         ) x
    WHERE is_leaf = 'true'
    ;
    
  • Extract the value between the xml tags in the XML inside the BLOB field

    Hello

    I have a table that contains a BLOB column, this XML file to store column that received from an external source. Now for one of my needs. I need to read that value is the specific XML tag and create the entry in the database.

    Column name DataType
    IDNumber
    RecordBLOB OBJECT

    This is the XML code that is stored in the file inside the BLOB field format. XML below, I need go get AMC1234 there is after < itemName > text < / itemName > I thought to use XMLTYPE, but unfortunately my DBA team does not XML database, I now use UTL_RAW. CAST_TO_VARCHAR2 and recovery entire string, but I am not able to read actual result it takes. Can someone help me remove AMC1234.

    <? XML version = "1.0"? >

    <! DOCTYPE importFile SYSTEM "xyz.dtd" >

    -< importFile >

    -< importResult >

    < mode status = "DΘFINIR" > general failure < / status >

    < statusCode > 1 < / statusCode >

    invalid < errorMsg > list and holiday component < / errorMsg >

    -< returnInfo >

    < itemName > PRQ < / itemName >

    < Valeurelement > CBA < / Valeurelement >

    < / returnInfo >

    -< returnInfo >

    < itemName > LMP < / itemName >

    < Valeurelement > CBA < / Valeurelement >

    < / returnInfo >

    -< returnInfo >

    < itemName > KEY < / itemName >

    < Valeurelement > 9999 < / Valeurelement >

    < / returnInfo >

    -< returnInfo >

    < itemName > text < / itemName >

    < Valeurelement > AMC1234, FIXED_ALL, RED < / Valeurelement >

    < / returnInfo >

    < / importResult >

    < / importFile >


    Thank you

    Without

    Without - try something like...

    with t as (select"

    -

    -

    General failure

    1

    component and invalid vacation list

    -

    PRQ

    ABC

    -

    LMP

    ABC

    -

    KEY

    9999

    -

    Text

    AMC1234, FIXED_ALL, RED

    "the double pass."

    )

    Select Replace (regexp_substr (col,'([^<>']) itemName))

    , replace (regexp_substr (col,'([^<>""]) Valeurelement))

    t

    connection of level <=> ');

  • How to read the data with different XML schemas within the unique connection?

    • I have Oracle database 11g
    • I access it via JDBC: Slim, version 11.2.0.3, same as xdb.
    • I have several tables, each has an XMLType column, all based on patterns.
    • There are three XML schemas different registered in the DB
    • Maybe I need to read the XML data in multiple tables.
    • If all the XMLTypes have the same XML schema, there is no problem,
    • If patterns are different, the second reading will throw BindXMLException.
    • If I reset the connection between the readings of the XMLType column with different schemas, it works.

    The question is: How can I configure the driver, or the connection to be able to read the data with different XML schemas without resetting the connection (which is expensive).

    Code to get data from XMLType is the implementation of case study:

     1   ResultSet resultSet = statement.executeQuery( sql ) ; 
    2   String result = null ;
    3    while(resultSet.next()) {
    4   SQLXML sqlxml = resultSet.getSQLXML(1) ;
    5   result = sqlxml.getString() ;
    6   sqlxml.free();
    7   }
    8   resultSet.close();
    9    return result ;

    It turns out, that I needed to serialize the XML on the server and read it as BLOB. Like this:

     1    final Statement statement = connection.createStatement() ;  2    final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;  3   ResultSet resultSet = statement.executeQuery( sql ) ;  4   String result = null ;  5    while(resultSet.next()) {  6   Blob blob = resultSet.getBlob( 1 );  7   InputStream inputStream = blob.getBinaryStream();  8   result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();  9   inputStream.close(); 10   blob.free(); 11   } 12   resultSet.close(); 13   statement.close(); 14  15   System.out.println( result ); 16    return result ; 17
    

    Then it works. Still, can't get it work with XMLType in resultset. On the customer XML unwrapping explodes trying to pass to another XML schema. JDBC/XDB problem?

  • How to read report .xml to a printer?

    How to read the .xml report that is sent by e-mail?  You open the file with something?

    Use the player to open the file. The report should be readable on the side of keft.

  • How to read the text of an XML with the dom parser?

    Hi all

    It's my code. How will I be able to read the text inside the xml file using dom parser?

    my xml file is like this...



     
        LLEYTON
        Hewitt
        Australian
       
        1
        897
       

     


        André
        Agassi
        American
       
        2
        679
       

     

    which I stored in _xml.

    InputStream is = getClass () .getResourceAsStream (_xml);

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();

    DocumentBuilder db = dbf.newDocumentBuilder ();

    Doc document = db.parse (is);

    NodeList nl = doc.getElementsByTagName("*");

    for (int i = 0; i)< nl.getlength();="">

    {

    System.out.println ("node name" + nl.item (i) .getNodeName ());  Player, firstname, lastname, tennis o/p

    System.out.println ("node value" + nl.item (i) .getTextContent ());  o/p value null, null, null, null

    }

    I want the text in the first name should get displayed as "Lleyton" and any other text in other tags as Andre/Agassi/American/2/679

    You can install JDE and operates the samples, you will find XMLDEMO that will help you read XML application blackberry;

    good luck;

  • How to do a bunch of fields read only value-based

    IM using jdev 12.1.2.

    I have a fragment with a few dozen jsff fields. I need to make these read-only or editable fields based on a value. I know how to do this for each field, but I was hoping there was a way to do this for each of them with a single property. For instance, all the fields are in a panelgrouplayout or a panelformlayout can I set a property on this provision which will set then all areas reporting to him read-only. I was just trying not to put the property read-only on each field of monkey.

    There is none of these goods or componentwhich allows you to do. All you can do is to set the readonly property of each field to the same property (bean or pagedef) and ppr the container so that the components are updated.

    Or you use a bean method that sets all the fields editiable readonly properties in a contianer orf true false. It would save that you set the property for each field.

    Timo

  • How to read the values of the field of LOV disabled?

    Hi all

    I have a requirement, based on values that we entered one of the LOV fields, then we are arising from the new values based on the value that we entered this field of LOV. And then I must by default new LOV values derived in a two other fields of LOV and then disable them. Once the fields are disabled, then I'm not able to read the values using the pagecontext.getparameter... I get nothing when I tried to read using the pagecontext.getparameter.

    Pointers on how to read the values of disabled field/LOV?

    Thank you
    Clarriiza

    1. you already have values, and that's what you set in the LOV before turning off, right? So why do you need to recover again from the LOV.

    2. are you disabling or making it readonly? I think that if it is disabled, you might still be able to get the value using pageContext.getParameter.

    3 have you tried to get the handle to the LOV bean and get the value using lovBean.getValue (pageContext)?

    4. another Option is to combine the value of a FormValue Bean also (as well as the LOV bean) and retrieve it from FormValue.

    5 BTW, why are, why you're seen LOV if you disable it? Can't you just a TextBox?

    See you soon

    AJ

  • Reading BLOB fields

    Experts-


    Is it possible that we can read the data in the column of table in database BLOB fields in Short 3.0?

    Have we not some direct for BLOB fields readers ? Point No. 2 gold below is the correct way to short?

    Below are some details that I could gather from google/search:

    1. http://docs.Oracle.com/CD/E29585_01/DeveloperStudio.61x/DevStudioHelp.PDF in other words directly CLOB / BLOB is not supported by SHORT
    2. https://forums.oracle.com/thread/2426178 - indicates a replacement for reading the sources BLOB' Oracle Advanced short JDBC Manager column 6.1.2 for generic platform '


    Any help/pointers is very appreciated.

    Thank you

    Ranish

    Please see thread external clover: http://forum.cloveretl.com/viewtopic.php?f=4&t=6644

    That address this issue!

  • How to read the data of BLOB and save to the file system

    Hi friends.

    I have called DEMO table there image stored as a BLOB. now my requirement is to know how to read the data of BLOB and saved in the file system. is there a procedure
    to read the blob object and stored in the file system. pls suggest me with an example.
    Thank you

    HI - don't know what version you have, but have a read through this:

    http://www.Oracle-base.com/articles/9i/ExportBlob9i.php

    Hoek link is to import the blobs in the db, it is export, to a file.

  • How to load the image into the Blob field in Sql?

    Hello

    I want to know how to load the image into the Blob field in Sql

    Concerning


    Therese

    Re: How to load the image into the Long Raw column?

Maybe you are looking for