Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: to insert into blob
> 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;
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
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