Problem with loading file to BLOB column
555294Jan 18 2007 — edited Jan 18 2007I am attempting to load up a .gif gile into a BLOB column in my database.
I created the directory as below:
===
SQL> create or replace directory example_lob_dir as 'C:\temp';
Directory created.
===
Next I created the following procedure to load the file into the BLOB column:
====
create or replace procedure load_blob as
dest_loc blob; -- destination location
src_loc bfile := bfilename('example_lob_dir', 'example.gif'); -- source location
begin
-- Insert intial BLOB value
insert into test_blob(id, file_name, image)
values (1, 'test.gif', empty_blob())
returning image into dest_loc;
-- Open the source BFILE
dbms_lob.open(src_loc, dbms_lob.lob_readonly);
-- Open the LOB (optional)
dbms_lob.open(dest_loc, dbms_lob.lob_readwrite);
-- Load the file
dbms_lob.loadfromfile(
dest_lob => dest_loc,
src_lob => src_loc,
amount => dbms_lob.getlength(src_loc));
-- Close LOBs
dbms_lob.close(dest_loc);
dbms_lob.close(src_loc);
commit;
end load_blob;
===
The file is definitely in the C:\temp folder and is named correctly. I am working in WinXP with Oracle10gXE and both server and client are on the same machine.
The procedure compiles without any errors but when I attempt to run it I get an error message as below:
==
SQL> exec load_blob
BEGIN load_blob; END;
*
ERROR at line 1:
ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "SYS.DBMS_LOB", line 716
ORA-06512: at "FTM.LOAD_BLOB", line 14
ORA-06512: at line 1
==
Any help would be much appreciated.