Converting BLOB to File

Hello Friends,
We have a requirement, we need to convert BLOB value as file and store it on unix box. Can we have only PLSQL for copying BLOB into a file and storing? Does it works for all the kinds of files with huze amout of data say 50 MB of data (or even more some times ) thi files are like .doc, .jpeg, .bmp, .pdf , .zip ...etc.
Please give your suggestion on solving this.
I will be thankful if you could give code snippet for this.
Regards
Sravan

Thank You. We are using UTL_FILE.put_raw procedure to write to a file .
We found it is working fine for .doc, .pdf, .jpeg.
The same procedure failing while uploading .bmp files.
Could you please tell is it required to handle different files differently? If so how do we differentiate these.
Thank you again.

Similar Messages

  • Parsing BLOB (CSV file with special characters) into table

    Hello everyone,
    In my application, user uploads a CSV file (it is stored as BLOB), which is later read and parsed into table. The parsing engine is shown bellow...
    The problem is, that it won't read national characters as Ö, Ü etc., they simply dissapear.
    Is there any CSV parser that supports national characters? Or, said in other words - is it possible to read BLOB by characters (where characters can be Ö, Ü etc.)?
    Regards,
    Adam
      |
      | helper function for csv parsing
      |
      +-----------------------------------------------*/
      FUNCTION hex_to_decimal(p_hex_str in varchar2) return number
      --this function is based on one by Connor McDonald
        --http://www.jlcomp.demon.co.uk/faq/base_convert.html
       is
        v_dec number;
        v_hex varchar2(16) := '0123456789ABCDEF';
      begin
        v_dec := 0;
        for indx in 1 .. length(p_hex_str) loop
          v_dec := v_dec * 16 + instr(v_hex, upper(substr(p_hex_str, indx, 1))) - 1;
        end loop;
        return v_dec;
      end hex_to_decimal;
      |
      | csv parsing
      |
      +-----------------------------------------------*/
      FUNCTION parse_csv_to_imp_table(in_import_id in number) RETURN boolean IS
        PRAGMA autonomous_transaction;
        v_blob_data   BLOB;
        n_blob_len    NUMBER;
        v_entity_name VARCHAR2(100);
        n_skip_rows   INTEGER;
        n_columns     INTEGER;
        n_col         INTEGER := 0;
        n_position    NUMBER;
        v_raw_chunk   RAW(10000);
        v_char        CHAR(1);
        c_chunk_len   number := 1;
        v_line        VARCHAR2(32767) := NULL;
        n_rows        number := 0;
        n_temp        number;
      BEGIN
        -- shortened
        n_blob_len := dbms_lob.getlength(v_blob_data);
        n_position := 1;
        -- Read and convert binary to char
        WHILE (n_position <= n_blob_len) LOOP
          v_raw_chunk := dbms_lob.substr(v_blob_data, c_chunk_len, n_position);
          v_char      := chr(hex_to_decimal(rawtohex(v_raw_chunk)));
          n_temp      := ascii(v_char);
          n_position  := n_position + c_chunk_len;
          -- When a whole line is retrieved
          IF v_char = CHR(10) THEN
            n_rows := n_rows + 1;
            if n_rows > n_skip_rows then
              -- Shortened
              -- Perform some action with the line (store into table etc.)
            end if;
            -- Clear out
            v_line := NULL;
            n_col := 0;
          ELSIF v_char != chr(10) and v_char != chr(13) THEN
            v_line := v_line || v_char;
            if v_char = ';' then
              n_col := n_col+1;
            end if;
          END IF;
        END LOOP;
        COMMIT;
        return true;
      EXCEPTION
         -- some exception handling
      END;

    Uploading CSV files into LOB columns and then reading them in PL/SQL: [It&#146;s|http://forums.oracle.com/forums/thread.jspa?messageID=3454184&#3454184] Re: Reading a Blob (CSV file) and displaying the contents Re: Associative Array and Blob Number of rows in a clob doncha know.
    Anyway, it woudl help if you gave us some basic information: database version and NLS settings would seem particularly relevant here.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Converting BLOB to Varchar

    How can I convert a large BLOB to a varchar within Oracle? I tried to fetch the BLOB field to put into a VARCHAR2 field, but, if I select more than 4000, It is throwing an error - ORA:06502 PL/SQL: numeric or value error: raw variable length too long.
    Here is the query I executed for the blob datatype conversion in crystal reports and works fine but I am losing half of the document. If I put 4001, I get the error message above.
    SELECT package_id,
    (dbms_lob.substr(STORED_DOCS(IMPORT_PACKAGE_STORE. STORED_DOCUMENT),4000)) as stored
    FROM
    IMPORT_PACKAGE_STORE
    where package_id=1
    Here's the function STORED_DOCS...
    create or replace function STORED_DOCS(B BLOB)
    return clob is
    c clob;
    n number;
    begin
    if (b is null) then
    return null;
    end if;
    if (length(b)=0) then
    return empty_clob();
    end if;
    dbms_lob.createtemporary(c,true);
    n:=1;
    while (n+32767<=length(b)) loop
    dbms_lob.writeappend(c,32767,utl_raw.cast_to_varchar2(dbms_lob.substr(b,32767,n)));
    n:=n+32767;
    end loop;
    dbms_lob.writeappend(c,length(b)-n+1,utl_raw.cast_to_varchar2(dbms_lob.substr(b,length(b)-n+1,n)));
    return c;
    end;
    My question is: Is there any way to fetch more than 4000 char BLOB field into a VARCHAR2 field.?

    dhanu !! wrote:
    Hi,
    I have a table with a column type blob. This column has a file contents which is either encoded in utf-8 or utf-16 format. When the encoding is utf-16, if query the database and try access the column contents by converting blob data into clob (or blob to varchar)How do you check this? Is there any other column in the table which stores this information?
    - I do not see any valid data in the query result. All I get is inverted "?" and boxes suggesting invalid data.Most probably database and client character set mismatch or your client is not able to render the required font?

  • How to convert blob data into clob using plsql

    hi all,
    I have requirement to convert blob column into clob .
    version details
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    DECLARE
       v_blob      temp.blob_column%TYPE;------this is blob data type column contains  (CSV file which is  inserted  from screens)
       v_clob      CLOB; --i want to copy blob column data into this clob
       v_warning   NUMBER;
    BEGIN
       SELECT blob_column
         INTO v_blob
         FROM temp
        WHERE pk = 75000676;
       DBMS_LOB.converttoclob (dest_lob          => v_clob,
                               src_blob          => v_blob,
                               amount            => DBMS_LOB.lobmaxsize,
                               dest_offset       => 1,
                               src_offset        => 1,
                               blob_csid         => 1, -- what  is the use of this parameter
                               lang_context      => 1,
                               warning           => v_warning
       DBMS_OUTPUT.put_line (v_warning);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SQLCODE);
          DBMS_OUTPUT.put_line (SQLERRM);
    END;I am not getting what is the use of blob_csid , lang_context parameters after going the trough the documentation .
    Any help in this regard would be highly appreciated .......
    Thanks
    Edited by: prakash on Feb 5, 2012 11:41 PM

    Post the 4 digit Oracle version.
    Did you read the Doc for DBMS_LOB.CONVERTTOCLOB? - http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm
    The function can convert data from one character set to another. If the source data uses a different character set than the target you need to provide the character set id of the source data.
    The blob_csid parameter is where you would provide the value for the source character set.
    If the source and target use the same character set then just pass zero. Your code is passing a one.
    >
    General Notes
    You must specify the character set of the source data in the blob_csid parameter. You can pass a zero value for blob_csid. When you do so, the database assumes that the BLOB contains character data in the same character set as the destination CLOB.
    >
    Same for 'lang_context' - your code is using 1; just use 0. It is an IN OUT
    >
    lang_context
    (IN) Language context, such as shift status, for the current conversion.
    (OUT) The language context at the time when the current conversion is done.
    This information is returned so you can use it for subsequent conversions without losing or misinterpreting any source data. For the very first conversion, or if do not care, use the default value of zero.

  • Problem writing image(Blob) to file

    Hi ,
    I'm trying to write image to file. The Image(26KB) is stored in database as BLOB. I have to change this to CLOB because when I try to write to file its writing all junk data. So I converted BLOB to CLOB then I try to write its giving me error.
    ORA-21560 :argument string is null, invalid, or out of range
    Cause: The argument is expecting a non-null, valid value but the argument value passed in is null, invalid, or out of range. Examples include when the LOB/FILE positional or size argument has a value outside the range 1 through (4GB - 1), or when an invalid open mode is used to open a file, etc.
    Action: Check your program and correct the caller of the routine to not pass a null, invalid or out-of-range argument value.
    The size of IMAGE after coverting to CLOB is 21102 bytes which is between the range.
    Here is how my code looks like:
    DECLARE
    f UTL_FILE.file_type;
    l_blob_len INTEGER;
    buffer VARCHAR2 (32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER (38);
    l_blob BLOB;
    l_clob CLOB := 'x';
    l_dest_offsset INTEGER := 1;
    l_src_offsset INTEGER := 1;
    l_lang_context INTEGER := DBMS_LOB.default_lang_ctx;
    l_warning INTEGER;
    BEGIN
    SELECT blobdata
    INTO l_blob
    FROM lob_table ip
    WHERE ip.id = 2;
    DBMS_LOB.converttoclob (dest_lob => l_clob,
    src_blob => l_blob,
    amount => DBMS_LOB.lobmaxsize,
    dest_offset => l_dest_offsset,
    src_offset => l_src_offsset,
    blob_csid => DBMS_LOB.default_csid,
    lang_context => l_lang_context,
    warning => l_warning);
    amount := buffer_size;
    offset := 1;
    f := UTL_FILE.fopen ('IN_FILE_LOC', 'something.doc', 'w');
    WHILE amount >= buffer_size
    LOOP
    DBMS_OUTPUT.put_line ('buffer_size');
    DBMS_LOB.READ (l_clob,
    amount,
    offset,
    buffer);
    UTL_FILE.PUT (f, buffer);
    UTL_FILE.FFLUSH (f);
    END LOOP;
    UTL_FILE.fclose (f);
    END;
    Please tell me what did I do wrong.

    Try this posts
    http://www.oracle-base.com/articles/9i/ExportBlob9i.php
    http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96591/adl06faq.htm

  • How to email BLOB as file attachment

    Hi folks,
    Seems I'm not the only one wanting to send emails with db BLOBs as file attachments, so let's see if we can find a solution.
    My app currently sends email using UTL_MAIL.SEND.
    If the BLOB I want to attach could be converted to RAW, would UTL_MAIL.SEND_ATTACH_RAW work? If so, is there a method of converting BLOB to RAW?
    We don't have Collaboration Suite, but surely CS lets you email BLOBs as file attachments, doesn't it? If so, there's a way...
    All assistance appreciated
    John D

    jd,
    I did something similar recently using demo_mail package. Do a search in the forum on "demo_mail hum_mail" (no quotes).
    Mine was a file on disk but the code has some info on using BLOBs as well.
    If you like, email me direct and I'll get you the code ([email protected])
    Greg

  • ALL MY DESKTOP APPS CONVERTED TO PDF FILES.

    After sending an urgent email attachment in Adobe PDF to Government Offcom, all my Desktop applications in windows 7 64 bit have been converted to PDF files and cannot be opened.   The attachment used was sent to me by my Secretary remotely using an old MAC.
    I can return my laptop to normal operation by un installing my Adobe Reader 11 app, but the problem returns when I re Download Adobe Reader
    11 again.     After discussing this with Adobe Technical in London they advised me to raise this issue with your Adjudicators in this Forum. 
    Please assist asap as this is very urgent right now for several genuine reasons.
    Many thanks.   Derek Horder.

    See if anything in here helps: https://helpx.adobe.com/acrobat/kb/application-file-icons-change-acrobat.html

  • How can I convert an audio file (speech) into a text?

    Hello everybody!
      Can someone explain how I can convert a garageband file (voice speech) into a text? My Mac is a Mac OS X 10.5.8 version, so I don't have programs such as mountain Lion. I thought to use googlevoice. Is this option available? If yes, how can I use it?
    Thanks.

    Hello, I only find google voice available for Abdroid!?
    http://www.ehow.com/info_10033225_google-voice-system-requirements-android.html
    Some possibilitities, not sure if they have 10.5.8 compatble versions anymore...
    http://atmac.org/speech-to-text-dictation-software-for-os-x
    Some reviews of later Dragon Speak...
    http://www.finetunedmac.com/forums/ubbthreads.php?ubb=showflat&Number=22962

  • While saving a file, I have converted all my files to Pdf.  The only way to restore previous is to delete Adobe.  Does anyone have a soution?

    While saving a file, I have converted all my files to Pdf.  This made everything inaccessible, even Explorer.  I had to delete Adobe to get back to some of the previous files.  I tried to restore system to previous, but I kept getting a pop up message that said I did not have enough shadow space.  Does anyone have a solution?  Greatly appreciate your help.

    Application, file icons change to Acrobat/Reader icon

  • Is it wise to keep the Nikon camera files "DSC's"  after downloading them and converting to DNG files via Adobe converter for lightroom use. In other words do the DNG files have all the raw data I would ever need in processing or should I save the camera'

    Is it wise to keep the Nikon camera files "DSC's"  after downloading them and converting to DNG files via Adobe converter for lightroom use. In other words do the DNG files have all the raw data I would ever need in processing or should I save the camera's DSC files?

    DNG files do not contain some metadata supplied by the camera, which can be used by the manufacturer's software. Thus, if you don't keep the original Raw photo, you will lose this information.
    If your 1000% sure you're never going to use the manufacturer's software, then this isn't a problem. But who can be sure what software you will be using 10 years from now?

  • Looking for help with converting a ppsx file to a video format such as .mov or mp4

    Hi All,  I am looking for conversion software that will allow me to convert a ppsx file to a video file on OS10.5.8. 

    Hi Klaus1, Thanks for your response.  I can open and view the file without difficulty.  My issue is getting into a video format that I can upload to a Website for client viewing.  All the conersion products I can find are for a newer OS then 10.5.8.  I am working on a deadline of midnight tonight-and cannot upgrade that quickly.  So What I need is a conversion program that will still run on my OS

  • Which is the best software to convert the video files for itouch?

    I got a 3rd gen itouch. Is there any software that helps to convert the video files. so I can sync those files to my itouch. " Handbrake " used to work pretty good. but now i still can convert the video files to m4v format but itunes doesn't allow me to put those files in. Please Help!

    You may have different menu options than Half bit Bit Ah. The support page on how to do it is at https://support.apple.com/kb/TS1497. In part it says:
    If you did not purchase videos from the iTunes Store, they are may not be in a format that you can play on your iPhone/iPod. In many cases, you can convert them to the correct format using iTunes or QuickTime.
    * Using iTunes: Select a video and choose Advanced > Create iPod or iPhone Version
    * Using Mac OS X v10.6: Open the video in QuickTime Player and choose Share > iTunes and then select the iPhone & iPod option.
    Hope that helps!

  • After I connected my hard disk to a friend's windows system all my files have been converted to .ink files and do not open....what do i do? They had important content

    after connecting my hard disk to a windows laptop all my files have somehow converted to .ink files and are not accessible.....what do i do?

    What do you mean by "all files", surely only one category of files got their default open program changed.
    Choose the affected files, right click on an individual file, and "open with",...change to default program.
    For a group, right click > show info > open with > change ALL
    If more than one group of files has had its default opening program changed, a time machine roll-back would be the easy option. Do you have a TM backup?

  • All files are converted to Word files in my email program

    after siging in to change my pdf files into word files now all my files inserted on e-mails are transformed into word files...how can I change this please ?

    Hi Ulrsfch,
    When you convert a PDF file to Word, the PDF file remains on your system. So, files should not be automatically converted to a different format because you've signed on to ExportPDF. What may be happening is that the filename association has changed on your system, and your operating system has associated different file types with the .doc or .docx filename extension.  Are you on Mac OS or Windows?
    I look forward to hearing back from you.
    Best,
    Sara

  • Need to convert ajp video file to quicktime

    Need to convert ajp video file to quicktime any ideas?

    More info needed.
    Where is this file? What software made it? If Web based could you provide a link?

Maybe you are looking for