BLOB manipulation

Before we go with it as a standardized approach to storing documents in our database:
We found some code on AskTom which shows you how to upload and download BLOB fields to/from the database. It involved some code, definitely diverging from the simple INSERTs & SELECTs were accustomed to.
Is this really the best way to go about storing BLOB fields? I'm not talking about the exact method, but rather the fact that PL/SQL code is required (using DBMS_LOB etc).
Thanks,
Chuck

Sorry if I didn't mention:
We're using Forms, yes. Users select the file that they want to insert into the database, we use a Forms utility to copy that file to a drive mounted to the database server, and then Forms calls a db PACKAGE which locates that file using a DIRECTORY OBJECT, and then uploads it to the database.
For document retrieval, the BLOB is output to the same mounted file system using UTL_FILE, and then Forms calls a utility which locates the appropriate .exe for the file's file extension, and then it opens the file.
I'm sure there are other "same but different " solutions out there, I just wanted to make sure that we aren't making things more complicated than they need to be, before we standardize on this approach.
-Thanks,
Chuck

Similar Messages

  • Excel to Blob

    Hi,
    I have an Oracle Forms Application that generates an Excel file, and I need do transform the Excel file generated in a blob type. I generate the Excel file with Ole2 package, with the following code:
    OLE2.INVOKE(WORKBOOK,'SaveAs',FILENAME);
    How can I save the Excel file generated in a blob variable?
    Thanks,
    Murilo

    if you are using webutil have a look at...
    FUNCTION Client_To_DB( clientFile in VARCHAR2,
    tableName in VARCHAR2,
    columnName in VARCHAR2,
    whereClause in VARCHAR2,
    asynchronous in BOOLEAN default FALSE,
    callbackTrigger in VARCHAR2 default NULL) return BOOLEAN is
    ...or...
    FUNCTION Client_To_DB_With_Progress
    ( clientFile in VARCHAR2,
    tableName in VARCHAR2,
    columnName in VARCHAR2,
    whereClause in VARCHAR2,
    progressTitle in VARCHAR2,
    progressSubTitle in VARCHAR2,
    asynchronous in BOOLEAN default FALSE,
    callbackTrigger in VARCHAR2 default NULL) return BOOLEAN is
    And after looking at your code it appears that you are not using webutil. So, here is how to load a blob from a bfile and many other blob manipulations..
    http://download-east.oracle.com/docs/cd/B14117_01/appdev.101/b10796/adlob_da.htm

  • Using XDB for manipulating table BLOBS?

    Hi!
    I have got a database table with a BLOB column which contains MS Office documents.
    For editing the documents I have written a small application for downloading the document, edit it with Office and upload it again to the database. Can I use XDB for this task? If yes it would be easier to use because the users don't have to download and upload the documents...
    I would expect the following - when the user clicks for editing a document, I copy the blob-column to a temporary XDB directory (for example /public/editing). The document gets opened from the XDB directory (with file assosiation in the right office program) and the users edit and save the document directly to the XDB folder. When they have finished I update the table BLOB with the XDB file and remove the file from XDB.
    Can I use XDB therefore or do you know better solutions? I would be glad about any tips!
    Thanks
    Markus

    I assume that using the XML format for word documents is not an option... If is you register a dummy schema for WORD-ML (Don't try and register the complete schema) and then have a table level trigger to store the content back in your table.
    The problem is bi-directional..
    First, when the user wants to open a document how are you going to ensure that the 'virtual document' in the XML DB repository has the correct content. Even a trigger on XDB$RESOURCE cannot help here..
    Second, for writing the content back in theory a trigger on XDB$RESOURCE could work. However this is an unsupported confguration, since the trigger could slow down repository operation to the point where protocol timeouts could occur.
    The 11g XML DB repository events feature was designed to solve these problems...
    Message was edited by:
    mdrake

  • Unable to convert BLOB to XML using XMLTYPE

    Hello (XML) Experts
    I need your help with manipulating a BLOB column containing XML data - I am encountering the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00200: could not convert from encoding UTF-8 to WINDOWS-1252
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 283
    I am on Windows 7 64 bit, Oracle 11.2.0.3 64 bit and database character set is WE8MSWIN1252, NLS_LANG is set to AMERICAN_AMERICA.AL32UTF8. The BLOB column contains the following XML data:
    <?xml version="1.0" encoding="utf-8"?>
    <Root CRC="-4065505">
      <Header Converted="0">
        <Version Type="String" Value="512" />
        <Revision Type="String" Value="29" />
        <SunSystemsVersion Type="String" Value="" />
        <Date Type="String" Value="20080724" />
        <Time Type="String" Value="165953" />
        <DAG Type="String" Value="" />
        <ChkID Type="String" Value="" />
        <FormType Type="String" Value="1" />
        <DB Type="String" Value="AllBusinessUnits" />
        <FuncID Type="String" Value="SOE" />
        <Status Type="String" Value="" />
        <FileType Type="String" Value="SFL" />
        <Descriptions>
          <Default Type="String" Value="Sales Order Entry" />
          <L01 Type="String" Value="Sales Order Entry" />
          <L33 Type="String" Value="Saisie commande client" />
          <L34 Type="String" Value="Entrada de órdenes de venta" />
          <L39 Type="String" Value="Inserimento ordine di vendita" />
          <L49 Type="String" Value="Aufträge erfassen" />
          <L55 Type="String" Value="Entrada de pedido de venda" />
          <L81 Type="String" Value="å?—注オーダー入力" />
          <L86 Type="String" Value="销售订å?•å½•å…¥" />
          <L87 Type="String" Value="銷售訂單錄入" />
        </Descriptions>
      </Header>
    <FormDesignerAppVer Type="String" Value="5.1" SFLOnly="1" />
    </Root>I am using the XMLTYPE constructor and passing in the BLOB column and the character set id of the XML data stored in the BLOB column in order to extract and update a node in the XML as follows:
    select xmltype(srce_form_detail,873) from SRCE_FORM where 873 above corresponds to the utf-8 encoding of the XML data in the BLOB column i.e. AL32UTF8, but this results in the above error.
    I have also tried converting the BLOB to a CLOB first as below where BLOB2CLOB is a function that converts the BLOB to a CLOB:
    select xmltype(BLOB2CLOB(srce_form_detail)).EXTRACT('/Root/Header/DB').getStringVal() XMLSrc  from SRCE_FORM;This results in the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00210: expected '<' instead of '¿'
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 272
    ORA-06512: at line 1
    Looking at the XML in the BLOB I noticed that it contains a BOM(byte order mark) and this is causing the XML parsing to fail and I don't know how to deal with it and I don't want to simply SUBSTR it out.
    What I am trying to achieve is to extract the contents of the DB node in the XML and depending on its value I need to update the 'Value' part of that node. I am stuck at the point of extracting the contents of the DB node.
    I hope I have provided enough information and I would appreciate any suggestions on how best to resolve this - my XML knowledge is very limited so I would appreciate any help.
    Regards,
    Mohinder

    Hi Marc
    Thanks for your response.
    You are correct that the blob contains Japanese and Chinese characters but I was expecting that using the XMLTYPE constructor would convert the character set albeit with some data loss or then not display the Chinese and Japanese characters correctly.
    It seems to me that XMLTYPE is not handling/interpreting the BOM contained in the BLOB since even converting the BLOB to CLOB is resulting in an error. If I use SUBSTR and ignore the BOM to extract the XML from the BLOB then it works and as expected the Chinese and Japanese characters are not displayed correctly, they are displayed as '¿' corresponding to the lines beginning with L81, L86 & L87 , see below:
    select xmltype(SUBSTR(BLOB2CLOB(srce_form_detail),4)) from SRCE_FORM
    <?xml version="1.0" encoding="utf-8"?>
    <Root CRC="-4065505">
      <Header Converted="0">
        <Version Type="String" Value="512" />
        <Revision Type="String" Value="29" />
        <SunSystemsVersion Type="String" Value="" />
        <Date Type="String" Value="20080724" />
        <Time Type="String" Value="165953" />
        <DAG Type="String" Value="" />
        <ChkID Type="String" Value="" />
        <FormType Type="String" Value="1" />
        <DB Type="String" Value="AllBusinessUnits" />
        <FuncID Type="String" Value="SOE" />
        <Status Type="String" Value="" />
        <FileType Type="String" Value="SFL" />
        <Descriptions>
          <Default Type="String" Value="Sales Order Entry" />
          <L01 Type="String" Value="Sales Order Entry" />
          <L33 Type="String" Value="Saisie commande client" />
          <L34 Type="String" Value="Entrada de ¿¿rdenes de venta" />
          <L39 Type="String" Value="Inserimento ordine di vendita" />
          <L49 Type="String" Value="Auftr¿¿ge erfassen" />
          <L55 Type="String" Value="Entrada de pedido de venda" />
          <L81 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
          <L86 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
          <L87 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
        </Descriptions>
      </Header>Can you please let me know how I can extract the binary dump of the BLOB and post it on the forum as I don't know how to do this. Below is snippet of the hexadecimal dump, that includes the BOM. I can post the full hexadecimal dump if this can help you to reproduce the error ?
    EFBBBF3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D227574662D38223F3E0D0A3C526F6F74204352433D222D34303635353035223E0D0A20203C48656164657220436F6E7665727465643D2230223E0D0A202020203C56657273696F6E20547970653D22537472696E67222056616C75653D2235313222202F3E0D0A202020203C5265766973696F6E20547970653D22537472696E67222056616C75653D22323922202F3E0D0A202020203C53756E53797374656D7356657273696F6E20547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C4461746520547970653D22537472696E67222056616C75653D22323030383037323422202F3E0D0A202020203C54696D6520547970653D22537472696E67222056616C75653D2231363539353322202F3E0D0A202020203C44414720547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C43686B494420547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C466F726D5479706520547970653D22537472696E67222056616C75653D223122202F3E0D0A202020203C444220547970653D22537472696E67222056616C75653D22416C6C427573696E657373556E69747322202F3E0D0A202020203C46756E63494420547970653D22537472696E67222056616C75653D22534F4522202F3E0D0A202020203C53746174757320547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C46696C655479706520547970653D22537472696E67222056616C75653D2253464C22202F3E0D0A202020203C4465736372697074696F6E733E0D0A2020202020203C44656661756C7420547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C303120547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C333320547970653D22537472696E67222056616C75653D2253616973696520636F6D6D616E646520636C69656E7422202F3E0D0A2020202020203C4C333420547970653D22537472696E67222056616C75653D22456E747261646120646520C3B37264656E65732064652076656E746122202F3E0D0A2020202020203C4C333920547970653D22537472696E67222056616C75653D22496E736572696D656E746F206F7264696E652064692076656E6469746122202F3E0D0A2020202020203C4C343920547970653D22537472696E67222056616C75653D224175667472C3A4676520657266617373656E22202F3E0D0A2020202020203C4C353520547970653D22537472696E67222056616C75653D22456E74726164612064652070656469646F2064652076656E646122202F3E0D0A2020202020203C4C383120547970653D22537472696E67222056616C75653D22E58F97E6B3A8E382AAE383BCE38380E383BCE585A5E58A9B22202F3E0D0A2020202020203C4C383620547970653D22537472696E67222056616C75653D22E99480E594AEE8AEA2E58D95E5BD95E585A522202F3E0D0A2020202020203C4C383720547970653D22537472696E67222056616C75653D22E98AB7E594AEE8A882E596AEE98C84E585A522202F3E0D0A202020203C2F4465736372697074696F6E733E0D0A20203C2F4865616465723E0D0A20203C466F726D3E0D0A202020203C4372656174696F6E4C616E6720547970653D22537472696E67222056616C75653D223031222053464C4F6E6C793D223122202F3E0D0A202020203C416374696F6E733E0D0A2020202020203C5065726D697373696F6E73202F3E0D0A202020203C2F416374696F6E733E0D0A202020203C48656C70202F3E0D0A202020203C466F6E743E0D0A2020202020203C446566466F6E7453697A6520547970653D22496E7465676572222056616C75653D2238222053464C4F6E6C793D223122202F3E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D2244656661756C7422202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D532053616E7320536572696622202F3E0D0A2020202020203C2F466F6E743E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D22383122202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D5320554920476F7468696322202F3E0D0A2020202020203C2F466F6E743E0D0A202020203C2F466F6E743E0D0A202020203C436F6E74726F6C733E0D0A2020202020203C436F6E74726F6C3E0D0A20202020202020203C436F6E74726F6C5479706520547970653D22496E746567657222204644496E743D2231222056616C75653D223122202F3E0D0A20202020202020203C446973706C61795479706520547970653D22537472696E6722204644496E743D2230222056616C75653D22466F726D2057696E646F77222053464C4F6E6C793D223122202F3E0D0A20202020202020203C43617074696F6E20547970653D22537472696E6722204644496E743D2230222056616C75653D2253597C3F7C55547C3F7C3F3F3F3F3F3F22202F3E0DThe XML I posted so far is actually truncated as the full XML is quite big but I showed the beginning of it as this is the section I believe that is not being handled properly. Furthermore I am able to write the BLOB out to a file successfully without any errors using DBMS_LOB & UTL_FILE.PUT_RAW and this seems to handle the BOM without any issues but what I really need to do is read a single node in the XML and update it directly preferably using XMLTYPE directly with the BLOB.
    I would welcome your suggestions on how best to read a single node and update it when the XML is contained in a BLOB.
    Regards,
    Mohinder

  • Problem displaying PDF stored in BLOB column

    Hello everyone.
    I've been trying to follow this tutorial http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::p11_question_id:232814159006 on displaying PDFs stored in BLOB columns. This is being performed on Apex 4.2, with my DB running 11g. I've got my procedure, which I'll post below:
    create or replace procedure "PDF" (p_id IN gvo_documents.doc_id%type)
    is
        l_lob    blob;
        l_amt    number default 30;
        l_off   number default 1;
        l_raw   raw(4096);
    begin
        select contents into l_lob
            from gvo_documents
             where doc_id = p_id;
    -- make sure to change this for your type!
        owa_util.mime_header( 'application/pdf' );
        begin
            loop
              dbms_lob.read( l_lob, l_amt, l_off, l_raw );
              htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
              l_off := l_off+l_amt;
              l_amt := 4096;           
        end loop;
            exception
               when no_data_found then
                  NULL;
            end;
    end;
    I am trying to run this through a PL/SQL dynamic region and while I don't receive any error's, the content displayed is a huge mess of garbled text and odd characters. I've tried to run this procedure on numerous other document types, including word files and jpeg images, all with the necessary changes in my procedure, and regardless of what I use, I still get a large mess of strange characters. Does anyone have any information or ideas about why this is happening?

    If I understand correctly, your requirements needs to be broken down into two problems:
    1) click link that pops up a window displaying a new APEX page
    2) an APEX page the displays the document, not downloads it.
    I haven't done #1 (yet).
    However, you may be able to generate a URL that points to the new page as part of the SELECT statement for the Report.
    This has a related question, but no answer yet:
    open pdf in popup browser window
    The key is target="_blank" for the anchor tag.
    To generate the URL, you should use the APEX_UTIL.prepare_URL() function.
    If that doesn't work, a Dynamic Action that does some magical JavaScript stuff may be needed.
    For #2, I lost the URL that showed how to display a PDF as part of a "form" page.
    From what I remember:
    Start with a blank page with one blank HTML region (all the Items go in the HTML region)
    Add an Item for the PK/Doc_ID
    part I forgot Create a Data Manipulation Process
    - Automated Row Fetch
    - On Load - After Header
    - (stuff for your table/view)
    part I forgot Create an (I believe) "File Browser" item type. For Settings:
    - Storage Type "BLOB column specified in Item Source" (and place the column name of the BLOB there)
    - MIME Type Column: (column name) -- since you have multiple types, this is a MUST HAVE
    - Filename Column: (column name) -- I highly recommend you have this.
    - Content Disposition == INLINE <-- this is the kicker
    Also, you will need a Browser Plugin for each of the MIME Types (otherwise, the browser may try to 'download' the file)
    Browsers can handle Image types internally. Adobe's plugin can handle PDFs. I don't know about Word/Excel.
    Again, I don't remember the exact details, but that should cover most of it.
    MK

  • Apache FOP PDF Save in BLOB column

    Hi,
    I just want to call Apache FOP in an APEX process to create PDF reports and save these reports in a BLOB column in the same database. So I can email these reports in another process using APEX_MAIL. Does anyone know a way to achieve this?
    Thanks

    If I understand correctly, your requirements needs to be broken down into two problems:
    1) click link that pops up a window displaying a new APEX page
    2) an APEX page the displays the document, not downloads it.
    I haven't done #1 (yet).
    However, you may be able to generate a URL that points to the new page as part of the SELECT statement for the Report.
    This has a related question, but no answer yet:
    open pdf in popup browser window
    The key is target="_blank" for the anchor tag.
    To generate the URL, you should use the APEX_UTIL.prepare_URL() function.
    If that doesn't work, a Dynamic Action that does some magical JavaScript stuff may be needed.
    For #2, I lost the URL that showed how to display a PDF as part of a "form" page.
    From what I remember:
    Start with a blank page with one blank HTML region (all the Items go in the HTML region)
    Add an Item for the PK/Doc_ID
    part I forgot Create a Data Manipulation Process
    - Automated Row Fetch
    - On Load - After Header
    - (stuff for your table/view)
    part I forgot Create an (I believe) "File Browser" item type. For Settings:
    - Storage Type "BLOB column specified in Item Source" (and place the column name of the BLOB there)
    - MIME Type Column: (column name) -- since you have multiple types, this is a MUST HAVE
    - Filename Column: (column name) -- I highly recommend you have this.
    - Content Disposition == INLINE <-- this is the kicker
    Also, you will need a Browser Plugin for each of the MIME Types (otherwise, the browser may try to 'download' the file)
    Browsers can handle Image types internally. Adobe's plugin can handle PDFs. I don't know about Word/Excel.
    Again, I don't remember the exact details, but that should cover most of it.
    MK

  • Escaping special characters in RAW/BLOB

    Hi!
    I have a BLOB column that needs to be exported into a CSV Textfile. Sounds a bit scary but works fine when you escape the critical bytes.
    I need to do the following replacement:
    5C -> 5C 5C ( = \ )
    22 -> 5C 22 ( = " )
    00 -> 5C 30 ( = ?? )
    0A -> 5C 0A ( = LF )
    0D -> 5C 0D ( = CR )
    If I use the replace function on my raw string, I can replace the bytes representing characters or numbers without a problem. " and \ also works fine but the nonprintable ones don't work - I guess implicit type conversion to varchar is the cause.
    Anyway, I want to replace this stuff, but I couldn't find any native binary replace function. How can this be done? Do I have to write my own function? I fear byte by byte manipulation in PL/SQL on large data will not be very performing...
    Thanks, Mac

    so here's my function, feel free so use
    function get_raw_escaped (
    pv_data_source raw
    return raw
    is
    lv_data_escaped raw(32767) := null;
    lv_length          number;
    lv_offset          number;
    lv_chunk_bin     raw(100);
    lv_chunk_hex     varchar2(100);
    begin
         lv_length := utl_raw.length(pv_data_source);
         if lv_length = 0 then return null; end if;
         for lv_offset in 1..lv_length loop
              lv_chunk_bin := utl_raw.substr (pv_data_source, lv_offset, 1);
              lv_chunk_hex := rawtohex(lv_chunk_bin);
              CASE lv_chunk_hex
                   WHEN '00' THEN lv_chunk_hex := '5C30';
                   WHEN '0A' THEN lv_chunk_hex := '5C0A';
                   WHEN '0D' THEN lv_chunk_hex := '5C0D';
                   WHEN '22' THEN lv_chunk_hex := '5C22';
                   WHEN '5C' THEN lv_chunk_hex := '5C5C';
              ELSE null;
              END CASE;
              lv_chunk_bin := hextoraw(lv_chunk_hex);
              lv_data_escaped := utl_raw.concat(lv_data_escaped, lv_chunk_bin);
         end loop;
         return lv_data_escaped;
    end;

  • Blob to doc

    hi all,
    i have a OLE Container field in my forms where i am storing documents in doc format (blob as a table field).
    i am manipulating my OLE Container with DDE and ole2 for transfering data to the doc file(bookmark etc) and save it in the database.
    Now i want to bring the OLE Container field content(i.e doc file ) to a buffer and save it as a O/S file.
    please help

    What version of SharePoint are you using? And is this purely in reference to a singular document or have you several that you want to do this with?
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Manipulate BLOB column data

    Hi,
    I've database Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    I need help on manipulating BLOB column data. It is storing .msg file. I want to modify its 'Subject:' line. Below query gives me position of Subject line but when I'm trying to read its content before modifying it then it is giving me error as ORA-06502: PL/SQL: numeric or value error: raw variable length too long:
    SELECT dbms_lob.substr(case_content, dbms_lob.instr( blob_column, utl_raw.cast_to_raw('Subject')),50)
    FROM my_table
    But below query gives me position properly:
    SELECT dbms_lob.instr( blob_column,utl_raw.cast_to_raw('Subject'))
    FROM my_table
    Thanks in advance.
    Regards,
    Chintan

    Firstly I would be wary of doing any string manipulation of binary data (.msg file). Secondly are you sure you have the parameters in dbms_lob.substr the correct way round: http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_lob.htm#i999349 You are getting the substring of case_content, starting with an offset of 50 and taking n bytes/chars where n is the postion of hte first occurence of "Subject" in case_content.
    Ben

  • How to know thw document type in a blob data type

    Hi
    I'm creating a Picture resizer to resize all images in my Oracle Database Blob. Some records contain MS word document and not an image. Is it possible to know what is the type of the document save on the blob before I try to resize the image. I'm using VB.net 2005 and ODP.net connector.
    Thanks in advance.
    Fred
    Programmer Analyst
    [email protected]

    I would suggest keeping it simple. When storing the blob, store a type alnog with it to allow the manipulation of the data.
    We use a single table to store and deploy application code (Jar files), sql script, signatures, word,excel and PDF documents and images. The file type makes it easy to use the correct viewr for the data or control the extract use of the data (as in running sql scripts/deploying jar apps)

  • BLOB limit to 2MB

    I want to have a column BLOB and size limit to 2MB.
    10G rel 2

    pgoel wrote:
    Adding a trigger is another option.Nope. That one doesn't work for LOBs since they can be manipulated via DBMS_LOB, which bypasses row level triggers.
    One possible solution on the database side is something like
    SQL> create materialized view t_mv refresh fast on commit
      2  as select id, dbms_lob.getlength(x) len from t;
    Materialized view created.
    SQL> alter table t_mv add constraint t_mv_chk check (len < 100);
    Table altered.
    SQL> insert into t values (1, lpad('x', 200, 'x'));
    1 row created.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-02290: check constraint (TIM.T_MV_CHK) violated
    SQL> insert into t values (1, lpad('x', 99, 'x'));
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> declare
      2      l_clob clob;
      3  begin
      4      select x into l_clob from t where id = 1 for update;
      5      dbms_lob.writeappend(l_clob, 10000, lpad('x', 10000, 'x'));
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-02290: check constraint (TIM.T_MV_CHK) violated

  • Exctract a BLOB to file system

    Hello,
    I've saved some archives (PDFs, DOCs) in a BLOB Field with Initialize_Container built-in.
    How could I extract these archives to file system ? (inverse operation).
    Thanks. Regards.

    It depends on what OLE automation interfaces Acrobat Reader supports - you may need the full version of acrobat to do any decent manipulation.

  • Converting a RenderedOp to a BLOB

    Hi
    I have a database which stores images as BLOBS, I have no problem storing the images when I have the image file initially, however when I load the BLOB from the database to my Java application I allow people to modify the image which is converted to a RenderedOp, I want to be able to save this manipulated image to the database but obviously have no filename for the image, I was wondering is it possible to store this RenderedOp as a BLOB and if so how to do so?
    Cheers
    Richie

    BLOBS are a bit of a nightmare in JDBC. The Blob interface looks like it was designed by someone who didn't know what BLOBs are. In particular there's no method of creating a new java.sql.Blob, you can only retrive one from a database query.
    What I do for Postgress is to write my own implementation of java.sql.Blob which reads from a file when the driver does a getBinaryStream on it. Then setBlob on a PreparedStatement seems to store OK, at least on Postgress creating a new record.
    This is my "fake" Blob
    * FileBlob.java
    * Created on 06 April 2004, 09:00
    package org.figis.util;
    import java.io.InputStream;
    import java.sql.Blob;
    import java.sql.SQLException;
    * <p>{@link java.sql.Blob} object for inserting new BLOB into database from file.</p>
    * <p>This, to my mind, is a fairly ugly fudge to get arround the complete
    * ommision of a capability from JDBC. The alternative, in the case of Postgres,
    * is to access a proprietary interface.<p>
    * <p>When an instance of this class is supplied to a {@link java.sql.PreparedStatement}
    * Postgres (at least) creates a new Blob and copies the stream obtained from getBinaryStream()
    * into it, then it puts the BLOB reference into the SQL.<p>
    * <p>This might, or might not work with other databases.</p>
    * @version $Id: FileBlob.java,v 1.3 2004/07/28 16:49:00 malcolmm Exp $
    * @see java.sql.Blob
       @see java.sql.PreparedStatement
    * @author  malcolm
    public class FileBlob implements Blob {
        InputStream stream;
        long size;
         * Creates a new instance of FileBlob
         * @param stream Input stream with data
         * @param size Length of data
        public FileBlob(InputStream stream, long size) {
            this.stream = stream;
            this.size = size;
         * Create a new instance of FileBlob from a File object
         * @param file The existing file to copy
         * @throws IOException if file cannot be openned.
        public FileBlob(java.io.File file) throws java.io.IOException {
            this(new java.io.FileInputStream(file), file.length());
        /** Gets a stream containing the file data.
         * @throws SQLException Wrapped IO exception should file be duff
         * @return An inputStream
        public InputStream getBinaryStream() throws SQLException {
            return stream;
        /** Unsupported
         * @param pos start position
         * @param length bytes to read
         * @throws SQLException On read error
         * @return byte array
        public byte[] getBytes(long pos, int length) throws SQLException {
            throw new UnsupportedOperationException("getBytes");
        /** Get size of input data
         * @throws SQLException Retrieval error
         * @return Size in bytes
        public long length() throws SQLException {
            return size;
        /** Unsupported
         * @param pattern Pattern to find
         * @param start search start
         * @throws SQLException On access error
         * @return position
        public long position(byte[] pattern, long start) throws SQLException {
            throw new UnsupportedOperationException("position");
        public long position(Blob pattern, long start) throws SQLException {
            throw new UnsupportedOperationException("position");
        public java.io.OutputStream setBinaryStream(long pos) throws SQLException {
            throw new UnsupportedOperationException("setBinaryStream");
        public int setBytes(long pos, byte[] bytes) throws SQLException {
            throw new UnsupportedOperationException("setBytes");
        public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
            throw new UnsupportedOperationException("setBytes");
        public void truncate(long len) throws SQLException {
            throw new UnsupportedOperationException("truncate");

  • Manipulating XMLs in Oracle PL/SQL

    I have the following requirement:
    We have a BLOB field in one of the tables which stores XML files. We have a requirement wherein this XML file needs to be updated with latest data and stored back in the table. We are planning to write a stored procedure wherein we would first store the BLOB on the file system, make changes to the file and store it back to the database, and do all this in PL/SQL. I wanted to know how feasible it is to do all these operation in PL/SQL. What are the interfaces I will need to use for this? Or is it advisable to do the manipulation in frontend like .net and then store it back in the database? Kindly advise.

    XML is a text document so why you are storing it in a BLOB (Binary Large Object) rather than a CLOB (Character Large Object) I don't know.
    Anyway, Oracle provides a great deal of functionality for handling XML.
    If you were to convert it to a clob and thus an XMLTYPE datatype you can then use either SQL functionality with XQuery to update the required data before converting it back and storing it on the database or...
    you could use the DBMS_XMLDOM package to convert the clob into a DOMDocument from where you can traverse the nodes and do what you like with it before converting it back or...
    You could utilise the XMLDB (see XML DB Forum. FAQ here: XML DB FAQ to output your XML as a file, do some external processing and then re-read the XML.
    Many methods and you'll have to find the one that best suits your needs.

  • How to get blob image width with ordimage?

    Hello,
    I have trouble getting image width with ordimage. I have quite the same program for processing images as here: http://spendolini.blogspot.com/2005/10/manipulating-images-with-database.html
    so I have declared image files as BLOB files. How can I get the width for the them?
    There is a sample from ordimage reference:
    DECLARE
    image ORDSYS.ORDImage;
    width INTEGER;
    BEGIN
    SELECT p.product_photo INTO image FROM pm.online_media p
    WHERE p.product_id = 3515;
    -- Get the image width:
    width := image.getWidth();
    DBMS_OUTPUT.PUT_LINE('Width is ' || width);
    COMMIT;
    END;
    the ORDSYS.ORDIMAGE is used instead of BLOB here. when i do the same then i can't select BLOB content into the ORDSYS.ORDIMAGE variable. And otherwise I can't use the getWidth with the BLOB variable.
    Can anybody help please?

    Hi,
    the column blob_content is not suitable for storing into v_image2 because variable v_image2 is of type ORDSYS.ORDIMAGE and the column is BLOB.
    I used the following method instead:
    declare
    image blob;
    attributes clob;
    img_mimeType varchar2(32);
    img_width integer;
    img_height integer;
    img_contentLength integer;
    fileFormat varchar2(32);
    contentFormat varchar2(32);
    compressionFormat varchar2(32);
    begin
    DBMS_LOB.CREATETEMPORARY(attributes, TRUE, DBMS_LOB.CALL);
    select img
    into image
    from image_repository
    where id = 0;
    ORDSYS.ORDImage.getProperties(image,
    attributes,
    img_mimeType,
    img_width,
    img_height,
    fileFormat,
    compressionFormat,
    contentFormat,
    img_contentLength);
    dbms_output.put_line(img_mimeType);
    dbms_output.put_line(img_width);
    dbms_output.put_line(img_height);
    dbms_output.put_line(fileFormat);
    dbms_output.put_line(compressionFormat);
    dbms_output.put_line(contentFormat);
    dbms_output.put_line(img_contentLength);
    DBMS_LOB.FREETEMPORARY(attributes);
    end;
    try adapting this code and think about the possibility of "caching" image properties, because it takes some time to retrieve them every time.
    Bye,
    Flavio
    http://oraclequirks.blogspot.com/search/label/Apex

Maybe you are looking for

  • Drag and Drop without effect

    Hello, I have created a drag and drop following the examples provided by the documentation, and i didn't find any example without the zoom out effect during the drop. So now I have my drag and drop operation using the drag and drop manager and I woul

  • I have the tip of aux cable stuck inside the jack port. How can I get it out?

    The aux (audio) cable broke off inside the headphone port of my iPhone, it is stuck and I can't get it out. Can anyone help please? It is going to cost me a fortune to fix

  • IF and ELSE in OWB

    We are using OWB repository 10.2.0.2.0 and OWB client 10.2.0.2.8. The Oracle version is 10 G (10.2.0.2.0). OWB is installed on Sun 64 bit server. How do we use IF and ELSE structure in OWB/Expression? It gave me error on DECODE. I am able to use CASE

  • Missing redeemed card points

    Hi. I used to be able to see how much I had left off of my redeemed gift cards. But I cannot find that information anymore. I wanted to download some music, but can't because it charges my card instead and I can't choose another option. Do redeemed p

  • NES proxy to WL slow with IE

    WL 5.1sp4 Solaris 2.7 NES 3.63 We are experiencing slow connections/delays to WL pages when going through NES using Internet Explorer. Even on WL 404 error pages. The pages load quickly, but the browser keeps the connection open for a number of secon