Here is the code to load a file.
It's straight to load the file:
-- the table you want to load to
drop table blobs; create table blobs ( id varchar2(255), theBlob blob ) /-- declare a directory object
create or replace directory MY_FILES as '/export/home/tkyte/public_html';
-- script to load a file, aria.gif is the file to load:
declare l_bfile bfile; l_blob blob; begin insert into blobs values ( 'MyGif', empty_blob() ) return theBlob into l_blob; l_bfile := bfilename( 'MY_FILES', 'aria.gif' ); dbms_lob.loadfromfile( l_blob, l_bfile, dbms_lob.getlength(l_bfile) ); commit; end; /dbms_lob.loadfromfile does all the loading of file; the file must exist in the directory given by the MY_FILES directory.
This was first published in June 2002