Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: to insert into blob

Re: to insert into blob

From: Marin Dimitrov <marin_at_sirma.bg>
Date: Tue, 20 Feb 2001 02:44:13 -0800
Message-ID: <F001.002B8721.20010220014107@fatcity.com>

> I have a wav file and I have to insert it into a table with column blob
> type.
> How do I do this.
>

If u're working with JDBC then u should just open the OutputStream of the BLOB and write content from the .wav file's InputStream there.

If u want to do it only with the help of the DBMS_LOB package then you could take a look in the docs in the "Oracle8i Application Developer's Guide - Large Objects (LOBs) " chapter. There is an example for reading a file and storing the content into a BLOB that looks like :

/* Note that the example procedure loadLOBFromBFILE_proc is not part of the

   DBMS_LOB package: */
CREATE OR REPLACE PROCEDURE loadLOBFromBFILE_proc IS

   Dest_loc       BLOB;
   Src_loc        BFILE := BFILENAME('FRAME_DIR', 'Washington_frame');
   Amount         INTEGER := 4000;

BEGIN
   SELECT Frame INTO Dest_loc FROM Multimedia_tab

      WHERE Clip_ID = 3 FOR UPDATE;
   /* Opening the source BFILE is mandatory: */    DBMS_LOB.OPEN(Src_loc, DBMS_LOB.LOB_READONLY);    /* Opening the LOB is optional: */
   DBMS_LOB.OPEN(Dest_loc, DBMS_LOB.LOB_READWRITE);    DBMS_LOB.LOADFROMFILE(Dest_loc, Src_loc, Amount);    /* Closing the LOB is mandatory if you have opened it: */    DBMS_LOB.CLOSE(Dest_loc);
   DBMS_LOB.CLOSE(Src_loc);
   COMMIT;
END; Of course u should read the docs for details about the example (especially for details about CREATE DIRECTORY, BFILE, EMPTY_BLOB()).

hth,

    Marin



"When someone is seeking, it happens quite easily that he only sees the thing that he is seeking; that he is unable to find anything, unable to absorb anything, because he is only thinking of the thing he is seeking, because he is obsessed with his goal. Seeking means: to have a goal; but finding means: to be free, to be receptive, to have no goal. ..."
                                Herman Hesse, "Siddhartha"






-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Marin Dimitrov
  INET: marin_at_sirma.bg

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Feb 20 2001 - 04:44:13 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US