How to read/write a binary file from/to a table with BLOB column

I have create a table with a column of data type BLOB.
I can read/write an IMAGE file from/to the column of the table using:
READ_IMAGE_FILE
WRITE_IMAGE_FILE
How can I do the same for other binary files, e.g. aaaa.zip?

There is a package procedure dbms_lob.readblobfromfile to read BLOB's from file.
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#sthref3583
To write a BLOB to file you can use a Java procedure (pre Oracle 9i R2) or utl_file.put_raw (there is no dbms_lob.writelobtofile).
http://asktom.oracle.com/pls/ask/f?p=4950:8:1559124855641433424::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6379798216275

Similar Messages

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • How to read data in binary form from file?

    Hi,
    i try to write an implementation of LZW. I need to read data in binary form from a file. How can i do that? I cannot find something like "binary input stream" ...
    Thanks

    Hi,
    i try to write an implementation of LZW. I need to
    read data in binary form from a file. How can i do
    that? I cannot find something like "binary input
    stream" ...
    ThanksInputStream reads bytes. I don't understand your question.

  • How to read non-java binary file?

    Hello Team,
    I have problem to read non-java binary file.
    Let me explain.... I have one binary file created in vc++ having fix structure. Structure of file is like String,int,int,int.
    Now I have to read this file in my java application. I am failed to identify length of String value of Structure in java.
    Can any body help me to solve this problem?
    Thanks in advance.
    - Pathik

    Thanks for guide me,
    I have try using 0x00. And its working.
    Now I have another problem:
    in file.ext , I have written one record having structure string,int and int.
    I have enter data as "HelloWorld", 100 and 111.
    To read first record from file file.ext, following code I am using:
    try
         FileInputStream fis = new FileInputStream("file.ext");
         DataInputStream in = new DataInputStream(fis);
         char ch;
         while((ch=(char)in.readByte()) != 0x00)
              System.out.print(ch+"");
    System.out.println();
         System.out.println("Integer 1 --> " + in.readInt());
         System.out.println("Integer 2 --> " + in.readInt());
         in.close();
         fis.close();
    catch(Exception ex)
         System.out.println(ex.toString());
    And I am getting following output:
    HelloWorld
    Integer 1 --> 0
    Integer 2 --> 0
    File file.ext is created in vc++
    I am not getting integer data. Plz guide me for this problem.
    Thanks in advance
    - Pathik

  • Every time I open Firefox 4 I get a popup box saying: "OPENING FIREFOX SETUP 4.0.1.exe, Binary File from..." with different download link addresses

    Every time I open Firefox 4 a popup box keeps trying to get me to run setup again. The box always reads: "Opening Firefox Setup 4.0.1.exe, Binary File from...." followed by a link address, which is different every time. Recent addresses: http://mirror.umoss.org.......also http://mozilla.mirrors.tds.net....also http://mozilla.ussg.indiana.edu
    and so on.
    Help! Thanks!

    I am having the same problem and it seems to have just started (6/15/11). I have tried reloading the program several times and even the first release of the 4.o with no success. The same scenario also occurs when I click to open a new "tab" after the browser is already launched.

  • How to create a table from an existing table with new column

    Hi !
    Please help me.
    I want to create a table from an existing table with data and add two new column to the new table.
    What will be the syntax?

    craete table new_table as select a.*, 'somevalue' new_col1, 'somevalue'
    new_col2 from old_table a;Also there is a pitfall - newly created table will accept column type and precision from the select statement, so further you can be needed to modify columns
    if you want to have VARCHAR2 instead of CHAR for example:
    SQL> create table new_dept as select dept.*, 'New data' new_col from dept;
    Table created.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            CHAR(8)
    SQL> alter table new_dept modify (new_col varchar2(8));
    Table altered.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            VARCHAR2(8)Rgds.
    Didn't see michael's post - it reflects the fix for this problem using CAST.
    Message was edited by:
    dnikiforov

  • How to Read and Generate XML file from java code.

    hi guys,
    how to read the xml file (Condition :we know only DTD or Shema only).
    How to Generate the new xml file ?(using Shema )
    And one more how directly Generate the xml from DB?
    Pleas with code or any URL

    Using XMLbeans you can generate Java objects from an XSD schema (perhaps DTDs aswell)
    Then you can create an instance of the Document object and ask it to write itself.
    This will create an XML document complient to the schema.
    XMLBeans generates a "type" safe DOM where you can only ever have a structure compilent to you schema.
    matfud

  • How can I open different binary files from BLOB column ?

    If we store some type of binary file (XLS, DOC, PDF, EML and so on, not only pictures) in BLOB column how can I show the different contents? We use designer and forms 9i with PL/SQL.
    How can I copy the files from BLOB to file in a directory or how can I pass BLOB's content to the proper application directly to open it?

    The mime type is just a string as explained above (e.g. application/pdf...). There are lot of samples here and on metalink.
    E.g. add a column mime_type varchar(30) to your blob table. Create a procedure similar to the following:
    PROCEDURE getblob
    (P_FILE IN VARCHAR2
    IS
    vblob blob;
    vmime_type myblobs.mime_type%type;
    length number;
    begin
         select document, mime_type into vblob,vmime_type from myblobs where docname = p_file;
         length := dbms_lob.getlength(vblob);
         if length = 0 or vblob is null then
         htp.p('Document not available yet.');
         else
         owa_util.mime_header(vmime_type);
         htp.p('Content-Length: ' || dbms_lob.getlength(vblob));
         owa_util.http_header_close;
         wpg_docload.download_file(vblob);                
         end if;
    exception
         when others then
         htp.p(sqlerrm);
    END;
    Create a DAD on your application server (refer to documentation on how to create a DAD).
    Display the blob from forms (e.g. on a when-button-pressed trigger):
    web.show_document('http://myserver:port/DAD/getblob?p_file=myfilename','_blank');
    For storing blobs in a directory on your db server take a look at the dbms_lob package.
    For storing blobs in a directory on your app server take a look at WebUtil available on OTN.
    HTH
    Gerald Krieger

  • Read, Write and create files from java applet.

    Dear All,
    I have created a two files. One is applet and one application file. I am creating a instance of application file in applet. Application file is used for reading, writing and creating files. When I invoke applet from broser it dipslays error wrt file access permission. From the forum search I know that we need to sign the applet / edit the java policy to run the code locally. Final delivery of my code should execute on different system. Its not web. I have created a html page on submitting the form it invokes applet to read the form values from param and needs to update the values in xml file located locally. Please help me on how I can proceed with this fix.
    Thanks in advance.

    Sorry if I have not stated the problem clearly. I need to update content to files hosted in local system using java applets.
    I belive there are two ways to achive that.One with jar signer and one with modifying the java policy file. But this application needs to be installed in different system locally as I have created a application with webpage as useinterface and need to update the content in local files on submission. Not sure on how to modify the java.policy files in each end user system and whats the value we need to update in java policy file. Please help me on the steps to be followed

  • How can I write to a file from a livecycle designed PDF?

    I am producing a PDF in Livecycle designer and would like to write a sub-set of data from the document.
    I have tried methods such as exportData() but this exports everything which i don't need.
    I have seen another method which is to attach a file and write to that but ideally I'd just like to be able to create a new file.
    var data = xfa.data.nodes.item(0).nodes.item(1).saveXML()  var oFile = util.streamFromString(data , "utf-8");
    I would like to write oFile.
    Thanks in advance
    Edit:
    I would like to add that ideally the user would be presented with a save as dialog  box, so the can choose the location of where to save the xml data.

    an extraction out of expert one-on-one from Thomas Kyte
    <quote>
    when an oracle istance is created the services that support it are setup to 'log on as' the system (or operating system) account, this account has very few privileges and no acces to Window NT Domains. To access another Windows NT machine the OracleServiceXXXX must be setup to logon to the appropriate Windows NT Domain as a user who has acces to the required location for UTL_FILE.
    To change the default logon for the Oracle services go to (in Windows NT):
    Control Panel | Services | OracleServiceXXXX | startup | log on as; (where XXXX is the instance name)
    In Windows 2000, this would be:
    Control Panel | Administrative Tools | Services | OracleServiceXXX | Properties | Log on tab; (again XXXX is the instance name)
    Choose the This Account radio button, and then complete the appropriate domain login information. ONce the services have been setup as a user with the appropriate privileges, ther are two options dfor setting UTL_FILE_DIR:
    * Mapped Dirve: To use a mapped drive, the user that the service starts as must have setup a drive to match UTL_FILE_DIR and be logged onto the server when UTL_FILE is in use.
    * Universal Naming Convention: UNC is preferable to Mapped Drives because it does not require anyone to be logged on and utl_file_dir should be set to a name in the form \\<machine name>\<share name>\<path>
    You will of course need to stop and restart Oracle after changing the properties of the service.
    <\quote>
    I want to write some data to a (external) file. I have it working with the function UTL_FILE.
    My problem is I want to write to a file on a mapped drive (so a drive on a different machine). This is not working.
    Does anyone know a way to build this.
    Please send your responses to [email protected]
    Many thanks,
    Alex Nagtegaal

  • How to Read,Write & Update XML File

    hi,
    How to read,create and update an XML file using DOM

    xml API's are there like jdom and stuffs...
    search in google : xml API's + java

  • How to know exact size of table with blob column

    I have a table with one BLOB column. I ran this query.
    select bytes/1024/1024 from user_segments where segment_name='GMSSP_REQUEST_TEMP_FILES'
    (user_segments is a view)
    it gave me 0.125
    It means size of table is 0.125. I have uploaded 3 files to this table. Each of them is of 5 mb. After that I check size of table. but result was same. i.e 0.125.
    Can any body tell me how to know exact amount of space consumed by files. I am expecting following result
    size should be (5+5+5+0.125)MB
    Any help is appreciated.
    Thanks.
    Akie

    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1092.htm#i1581211
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:266215435203#993030200346552097

  • Error displaying a jpg file loaded into a table with blob field

    This may not be the correct forum for this question, but if it isn't could someone direct me to the correct one.
    I have created a table with a blob field in which I have loaded a jpg image. This appeared to work correctly, but when I try to display the image in internet explorer it comes back and tells me that it doesn't recognize the file type. Enclosed is the table create, load, and display pl/sql code. Can anyone tell me what I am doing wrong. Thanks. For the mime/header I used owa_util.mime_header('images/jpg') because my image is a jpg file.
    The database is 10g
    -- Create table
    create table PHOTOS
    IMAGEID NUMBER(10),
    IMAGE BLOB,
    IMAGE_NAME VARCHAR2(50)
    load image
    CREATE OR REPLACE PROCEDURE load_file ( p_id number, p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('SNAPUNCH', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO photos (imageid, image_name, image)
    VALUES (p_id , p_photo_name, EMPTY_BLOB())
    RETURNING image INTO dst_file;
    -- lock record
    SELECT image
    INTO dst_file
    FROM photos
    WHERE imageid = p_id AND image_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE photos
    SET image = dst_file
    WHERE imageid = p_id
    AND image_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;
    display image
    PROCEDURE display_image(p_id NUMBER) IS
    Photo BLOB;
    v_amt NUMBER DEFAULT 4096;
    v_off NUMBER DEFAULT 1;
    v_raw RAW(4096);
    BEGIN
    -- Get the blob image
    SELECT image
    INTO Photo
    FROM PHOTOS
    WHERE IMAGEID = p_id;
    owa_util.mime_header('images/jpg');
    BEGIN
    LOOP
    -- Read the BLOB
    dbms_lob.READ(Photo, v_amt, v_off, v_raw);
    -- Display image
    htp.prn(utl_raw.cast_to_varchar2(v_raw));
    v_off := v_off + v_amt;
    v_amt := 4096;
    END LOOP;
    dbms_lob.CLOSE(Photo);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    END;
    The url I enter is: http://webdev:7777/tisinfo/tis.tiss0011.Display_Image?p_id=1

    Just a little more information. When I enter owa_util.mime_header('image/jpeg') I can't display the file. It just shows up with a red x for the file.
    When I enter owa_util.mime_header('image/jpg') it displays the file, but in the format
    ¿¿¿¿JFIF¿¿-Intel(R) JPEG Library, version [2.0.16.48]¿¿C
    This is the way I would expect it to look if I opened it with Notepad, or an application that doesn't recognize jpg files. Can anyone tell me what I am doing wrong?? Thanks.

  • Migrating a table with BLOB column from one db to another

    Hello everybody,
    I have two databases D1 and D2. Each database contains table T1 (same structure in both databases). T has a BLOB column and is populated in D1. I have to move all the data from T database D1 into T database D2.
    D1 and D2 are located on different machines. T in D1 is a huge table (milions of records). What is the best solution to migrate the T data between the 2 databases?
    Any help will be appreciated.
    Thank you in advance.
    daniela

    Depending on the version of the database you have, you could use transportable tablespaces.
    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96524/c04space.htm#9370

  • Uploading a file (.doc, .xls, .txt) into an Oracle table with BLOB column

    Hello All :
    I have been trying to figure out for a simple code I can use in my JSP to upload a file (of any format) into an Oracle table with a BLOB column type. I have gone through a lot of existing forums but couldnot find a simple code (that doesnot use Servlet, for eg.) to implement this piece.
    Thanks a lot for your help !!

    Hi.
    First of all to put a file into Oracle you need to get the array of bytes byte[] for that file. For this use for example FileInputStream.
    After you get the byte array try to use this code:
            try {
                Connection conn = myGetDBConnection();
                PreparedStatement pstmt = conn.prepareStatement("INSERT INTO table1 (content) VALUES(?)");
                byte[] content = myGetFileAsBytes();
                if (content != null) {
                    pstmt.setBinaryStream(0, new ByteArrayInputStream(content), content.length);
                pstmt.close();
                conn.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }or instead of using ByteArrayInputStream try pstmt.setBinaryStream(0, new FileInputStream(yourFile), getFileSize());Hope this will help...
    regards, Victor Letunovsky

Maybe you are looking for

  • Toshiba Satellite C655 SP4168M freezes while playing a game

    So i've been having problems with mi laptop very recently with a game i'm playing (League of legends), the game normally works perfectly, but at random times it just completely freezes (making an awkward sttutering sound) and i have to forcefully shu

  • Table Reorg in R/3 System - eligibility of the table for reorg

    Hi Experts, We want to perform Table reorg in our R/3 system 4.7 EXT2. We have taken out top 10 tables which are candidates for table reorg based on Size, could you please let me know the below : How i can check that each table is eligible for table

  • Different types of Mapping in XI

    Hi All, I am new to XI, I know different types of Mapping in XI. when we are using this mapping? 1. Graphical Mapping 2. Java Mapping 3. XSLT Mapping and 4. ABAP Mapping Please give detail.. it's helpful to me... Thanks & Regards SReddy,

  • Preview in Source Monitor Failure - The Importer reported a generic error

    Hello, I was wondering whether anybody might be able to help me? I'm pretty new to editing and using Premier Pro so this could be something very simple. I've shot a load of footage on a Sony PMW200 (shot 1080/25p) and copied all my footage onto a G-R

  • Data Execution Prevention (DEP) issue....

    Vista installed SP2 last night....Have DEP issue today. Latest Flash PLayer is the culprit. DIsabling it doesn't help, only uninstalling does. Tried unistalling then reinstalling...Same problem. Any insights?