ORA-22288
80590Feb 4 2004 — edited Feb 5 2004I am attempting to load image files (gif, jpg, etc) into a table and keep getting the ORA-22288 error.
Here are the steps I've taken:
Log in as system.
SQL>grant create any directory to swisdata;
Log in as swisdata
SQL>create directory img2load as 'c:\temp';
SQL>create table sw_images(
img_key NUMBER NOT NULL,
img_name VARCHAR2(30),
img_mime VARCHAR2(30),
img_data BLOB,
primary key (img_key) );
Then I created this procedure to load the image files:
SQL>CREATE OR REPLACE PROCEDURE sw_load_image( position IN NUMBER, filename VARCHAR2) AS
f_lob BFILE;
b_lob BLOB;
image_name VARCHAR2(30);
mime_type VARCHAR2(30);
dot_pos NUMBER;
BEGIN
-- Find the position of the dot ('.') located in the filename
dot_pos := INSTR(filename, '.');
-- Get the filename without extension and use it as image name
image_name := SUBSTR(filename,1,dot_pos-1);
-- Build the mime type. Retrieve the file extension and add it to 'image/'
mime_type := 'image/'||SUBSTR( filename, dot_pos+1, length(filename) );
INSERT INTO sw_images values(position, image_name, mime_type, empty_blob() ) RETURN img_data INTO b_lob;
f_lob := BFILENAME('IMG2LOAD', filename);
dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
dbms_lob.loadfromfile(b_lob, f_lob, dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
COMMIT;
END;
/
I then put an image file in the directory on the database server and tried to run the procedure to load the image into the table. That is when I receive this error:
ORA-22288: file or LOB operation FILEOPEN failed
The system cannot find the file specified.
ORA-06512: at "SYS.DBMS_LOB", line 475
ORA-06512: at "SWISDATA.SW_LOAD_IMAGE", line 21
ORA-06512: at line 9
What else do I need to do?
Thanks,
Jason