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;
/

Tags: Database

Similar Questions

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

  • Download the image blob field

    Hello experts,

    I am trying to download an image via the input file to convert it to a blob field and then save it in the database.

    So I linked the value of the input file to create the blob through bean, I found on the internet.

    My Page binding components:

    < af:inputFile id = value = "#{UploadBean.file}" / 'inputImage' >

    < af:button text = 'Upload' id = 'btnUpload' action = "#{UploadBean.uploadImage}" / >


    My Bean:


    private BlobDomain img;

    private UploadedFile inasmuch;

    public UploadBean() {}

    Super();

    }

    public UploadedFile getFile() {}

    return inasmuch;

    }

    {} public void next (file UploadedFile)

    Inasmuch = file;

    }

    public void uploadImage() {}

    UploadedFile myfile = (UploadedFile) this.getFile ();

    IMG = createBlobDomain (myfile);

    System.out.println (IMG);

    }

    Private BlobDomain createBlobDomain (file UploadedFile) {}

    InputStream in = null;

    BlobDomain blobDomain = null;

    OutputStream out = null;

    try {}

    in = file.getInputStream ();

    blobDomain = new BlobDomain();

    out = blobDomain.getBinaryOutputStream ();

    ubyte [] buffer = new byte [8192];

    int bytesRead = 0;

    While ((bytesRead = in.read (buffer, 0, 8192))! = - 1) {}

    out. Write (buffer, 0, bytesRead);

    }

    in. Close();

    } catch (IOException e) {}

    e.printStackTrace ();

    } catch (SQLException e) {}

    e.fillInStackTrace ();

    }

    Return blobDomain;

    }

    But it seems to me that the file is still set to null after choosing an image, because it throws the following error message:

    <oracle.adf.common> <AdfDiagnosticsJarsVersionDumpImpl> <executeDump> <Pfad für den Dump der JAR-Version :C:\Users\user\AppData\Roaming\JDeveloper\system12.1.3.0.41.140521.1008\DefaultDomain\servers\DefaultServer\adr\diag\ofm\defaultdomain\defaultserver\incident\incdir_45/adf_DiagnosticsJarsVersionDump42_i45.txt>

    < oracle.dfw.impl.incident.DiagnosticsDataExtractorImpl > < DiagnosticsDataExtractorImpl > < createADRIncident > < 46 event mit Problemschlussel 'ADFC-00032 [ADFc]' is >

    < oracle.adf.view > < RichExceptionHandler > < _logUnhandledException > < ADF_FACES - 60098:Faces - empfangt nicht behandelte Exceptions in Phase INVOKE_APPLICATION 5 cases >

    javax.faces.FacesException: #{UploadBean.uploadImage}: //C:/Users/user/AppData/Roaming/JDeveloper/system12.1.3.0.41.140521.1008/o.j2ee/drs/REA/ViewPflegeWebApp.war/de/test/viewpflege/pages/UploadPage.jsff @13,85 action = "#{UploadBean.uploadImage}": java.lang.NullPointerException "

    ...

    What I'm missing or doing wrong?

    Uusing JDeveloper 12.1.3

    Thank you!

    Hello

    Make sure that the UsesUpload of the property in your page jspx is true.

    also, for more information check this: https://tompeez.wordpress.com/2011/11/26/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-1/

    Kind regards

    Habib

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

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

  • Unpacking error when you try to use UTL_COMPRESS. LZ_UNCOMPRESS to get the text XML 'payload' of a BLOB field

    Hi, really appreciate any pointers anyone may have with what I'm trying to do here... the crux of the matter, I have is the following:

    * Try to get the contents of a BLOB column directly in PL/SQL, zipped/compressed

    Uncompressed data are XML... below is an example quite pinked...

    <? XML version = "1.0"? >

    <! DOCTYPE TaskConfiguration >

    < TaskConfiguration >

    < MapKeySet >

    < macro keyboard Type = 'C' >

    namespace < Key > < / key >

    < value > B_O_BrokerChks < / value >

    < / macro keyboard >

    < / MapKeySet >

    < / TaskConfiguration >

    * I learned the information in the table of these pages & used all_directories + a pirated version of proc WRITEBLOBTOFILE (also from here) to get this data in a zip file. That worked fine and I can open the file that results with 7 - zip or explore (how I got the sample above)

    * I tried a few tweaks to the functions provided here to try to get the data directly into the pl/sql (ideally I would like to be able to enter in a type of XMLTYPE data & query only). However, that's where I'm struggling

    * I get the same error as I do with this 1-liner

    SELECT UTL_COMPRESS. LZ_UNCOMPRESS (XML) FROM FooBooBazVendorTab where REFERENCE_ID = 19834

    ORA-29294: A data error occurred during compression or decompression.

    ORA-06512: at "SYS." UTL_SYS_COMPRESS", line 56

    ORA-06512: at "SYS." UTL_SYS_COMPRESS', line 226

    ORA-06512: at "SYS." UTL_COMPRESS", line 89

    29294 00000 - "a data error occurred during compression or decompression."

    * Cause: An error occurred during compression or decompression input source.

    * Action: Verify that the source data is a set of data compressed or invalid.

    Info * @desc to the col de BLOB XML is as follows

    * I also read a ' UTL_COMPRESS. LZ_UNCOMPRESS cannot process the file gzip with FCOMMENT' thread here and I tried the potential workaround here who is trying to manipulate the content of the blob to remove the FCOMMENT... but nothing helps. I must say that I am not sure that it's actually my problem.

    Details on the Zip file I can glean from 7 - Zip are as follows...

    * Any ideas please? (If Oracle decompress may have a problem handling the XML data itself... with my way of thinking on the FCOMMENT being a bit of a furphy?)

    * Don't know if the zip file hexview can help, but just in case where is >

    I would be very grateful for any help you might be able to give me this.

    Rgds Neil

    UTL_COMPRESS use of LZ compression, which is a version less compression compared to normal ZIP files (that use LZW, often with additional ' Deflate' or other methods).

    Anton Scheffer (member of the these for one) wrote a package to compress and decompress found related to this article on his blog:

    Analysis of a Microsoft Word docx and unpack zipfiles, PL/SQL - Blog of AMIS

  • Oracle 9i excerpt/analyse XML in BLOB

    I have the table with the Blob column. In the column of the blog, I have data XML (see below).

    I tried to parse xml and get the note value '< GetTest >. How do I get there?

    Example table:

    create table SAMPLE_XML_TABLE
    (
      ID           NUMBER not null,
      XMLSTRING    BLOB,
    );
    

    <?xml version="1.0" standalone="no"?>
    <FromResponse xmlns="http://www.somewebsite.com/FromResponse">
      <Code>0000</Code>
      <Seller>
      <SellerServer>
      <Version>01</Version>
      <Sample>
      <GetTest>I wanted to get this Text</GetTest>
      </Sample>
      </SellerServer>
      </Seller>
    </FromResponse>
    

    And of course any fix untested untested code made things worse... * sigh *. DBMS_LOB.substr has an agenda of setting different than the regular substr.

    This solution has been tested (really!) and although it is not the most beautiful thing, it does the job

    Select dbms_lob.substr (xmlstring,

    DBMS_LOB. InStr(xmlString, '') - dbms_lob.instr (xmlstring, '') - length (''),

    DBMS_LOB. InStr (xmlstring, '') + length ('')) GetTest

    of sample_xml_table

  • Insert image into blob field in oracle

    Hello
    I'm below eror to insert the image file in the field of the block.


    ORA-22288: file or LOB FILEOPEN operation failed
    The system does not have the specified path.
    ORA-06512: at "SYS." DBMS_LOB", line 744

    Here's my SP:

    CREATE OR REPLACE PROCEDURE DRFSMS.iPAD_Image_Load(vParcel_ID IN VARCHAR2, vSerial_No IN NUMBER, vFileName IN VARCHAR2) IS
    l_source BFILE.
    l_dest BLOB;
    l_length directory.
    BEGIN

    l_source: = BFILENAME ("PHOTO_DIR", vFileName);

    INSERT IN WS_PARCEL_SS_IMAGES (Parcel_ID, Serial_No, fichier_image) VALUES (vParcel_ID, vSerial_No, EMPTY_BLOB ())
    RETURN fichier_image IN l_dest;
    -lock the folder
    SELECT fichier_image INTO l_dest FROM WS_PARCEL_SS_IMAGES WHERE PARCEL_ID = vParcel_ID AND Serial_No = vSerial_No FOR UPDATE;
    -Open the file
    DBMS_LOB. FileOpen (l_source, DBMS_LOB.file_readonly);
    -get the length
    l_length: = DBMS_LOB.getlength (l_source);
    -read the file and store it in the destination
    DBMS_LOB. LoadFromFile (l_dest, l_source, l_length);
    -update the blob with destination field
    UPDATE WS_PARCEL_SS_IMAGES SET fichier_image = l_dest WHERE PARCEL_ID = vParcel_ID AND Serial_No = vSerial_No;
    -close file
    DBMS_LOB. FileClose (l_source);
    END iPAD_Image_Load;

    below are the entries:

    DECLARE
    VPARCEL_ID VARCHAR2 (32767).
    NUMBER OF VSERIAL_NO;
    VFILENAME VARCHAR2 (32767).

    BEGIN
    VPARCEL_ID: = ' N00O-240';
    VSERIAL_NO: = 2;
    VFILENAME: = ' photo_dir/N00O - 222_1.jpg';

    DRFSMS. IPAD_IMAGE_LOAD (VPARCEL_ID, VSERIAL_NO, VFILENAME);
    COMMIT;
    END;

    pls someone please help me.
    thnx in advance.

    Kind regards

    Siddiq

    Published by: Siddiq on July 30, 2012 12:06

    How do you define PHOTO_DIR (which was the CREATE DIRECTORY statement)?
    Is the path to PHOTO_DIR a directory that exists on the server (and not on your client machine)?
    The user of the operating system that is running the database on the server Oracle has access to this directory on the server? Can you connect to the server as the operating system user that runs the Oracle database and open the file on the server?

    Justin

  • update the text with xml, DDL data fields a selection of an identification number

    Hi guys,.

    It should be simple, but I can't seem to find a straight answer.  In short:

    The XML file contains the ID, name, location (so 3 extreme records in the example xml file)

    Form contains a dynamic drop-down list to allow the selection of ID and text fields to display the names of the partners and the location of this ID.  The setting of the drop-down list works fine, however I need to update the associated name and location if different from the other ID's fields are selected.  I guess I'll need some sort of event on the menu drop down update other fields with the name and location of the selected ID, but I don't know enough to have a stab at him.

    Please, please, please help, Im starting to pull my hair.

    James.

    Sorry, looking at him again I could have given a better description of what is happening.

    Have a look at this sample https://acrobat.com/#d=NO5o6NhPTQgSYu3SVoN7rQ and data to go with her https://acrobat.com/#d=jN * pRT4uGg05VU * sGWvjcA

    The thing I should have said and I guess that's your problem is the the Data property, I used in $data. Data.resolveNode (...) must match the item parent of the element of your event if xml looks like

    1

    name 1

    Location1

    It should be $data.events.resolveNode (...)

    Maybe I should have used "itemGroup var = $data.resolveNode ("events.event.» (()_eventId.value_===_«_«_+_xfa.event.change+_»_») "); "in this case, but I try and do the resolveNode go as low as possible.

    Concerning

    Bruce

  • Use CF to write to the blob field and convert files

    I am trying to use cold fusion to extract a .doc to a database file, and then save it as a .pdf file. It will work to read character by character and then save it under a new name. Will this work and what is a good routine for her?

    You ask how do I retrieve a blob to a database field and save it in a file - or - how to convert a document to pdf format. If it is the latter, which really has nothing to do with ColdFusion.  There is no built-in feature in CF8 for convert .doc to .pdf format.  Therefore, you will need to use an external tool to do the conversion.  (If possible in CF9 using OpenOffice).

  • In REMOVED DB Blob field and save an image

    I need help. I have a db field 'image' of BLOB type and I save the contents to a file on a file local c: \ example.bmp.
    I found many examples
    BEGIN-
    Get LOB locator
    SELECT the image IN l_blob pc_immagini_blob FROM WHERE code = WCI;
    -Open the destination file.
    l_file: = UTL_FILE.fopen ("C: \ Temp ',' EXAMPLE.") BMP', 'w', 32767); -> error
    Pb is not local, but on an application server, the image must be saved in c: the customer. Help me??

    This might help you

    http://baigsorcl.blogspot.com/2010/02/storing-and-retrieving-images-Word.html

    http://baigsorcl.blogspot.com/search/label/WebUtil

  • When you insert a blob field which way is correct? (Transferred to another forum: jdbc)

    When we prepare a paper for the insertion of a row that contains the blob column. Is what sense this correct? And what is the difference?

    1 preparestatement.setblob(parameter number, blob type object)

    2 Preparestatement.setblob(parameter number, inputstream type object)

    Anyone know?

    When we prepare a paper for the insertion of a row that contains the blob column. Is what sense this correct? And what is the difference?

    1 preparestatement.setblob(parameter number, blob type object)

    2 Preparestatement.setblob(parameter number, inputstream type object)

    As suggested, you should post this question in the JDBC forum.

    Java Database Connectivity (JDBC)

    Before posting it see Chapter 14, "Working with LOBs and BFILE" in the JDBC Developer's Guide

    http://docs.Oracle.com/CD/B28359_01/Java.111/b31224/oralob.htm

    This chapter shows how to do what you are trying to do you and has the code example.

    Also for a character BLOB series are obsolete, since there is NO conversion is performed.

    With LOBs, you will need to first obtain a locator. Do you it by introducing a row first, and then ask Oracle returns the Locator for the LOB column. Then you can transfer the data using this index.

    The doc explain it.

  • Excel output format in the xml editor question field

    Hi all

    I have a problem with the release of excel as below.

    I developed a report to xml editor having exit excel, I designed the layout to the rtf model.

    one of the parameters in the report as 11000048,11000050

    so when I check the output excel the above setting is displayed as below.

    1,100,004,811,000,050

    But I need the parameter will be displayed in the format 11000048,11000050 , as written, please help me.

    Thank you

    Please try this

Maybe you are looking for