Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Insert data into LOB column
>
> I am new to working with LOBs. I want to insert data (through SQL or
PL/SQL)
> into a table that looks like this:
>
> column1 varchar2(100)
> column2 BLOB
> column3 number
>
> How can I insert data into that table directly?
>
> insert into table (column1, colum2, column3) values ('sample text', ?????,
> 12345);
>
> The BLOB can be a TXT-file or GIF-picture or bmp-picture. The file is
> locally stored on the hard drive.
>
I haven't done this with PL/SQL but peeking into the docs it seems that the u should follow the steps:
/* 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;
If u're familiar with Java/JDBC it's a lot easier to work with LOBs.
Anyways, the documentation should be sufficient to get the thing done.
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 Wed Feb 07 2001 - 03:11:43 CST