您好我正在尝试将图像添加到表格中。 我做了桌子:
create or replace
PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
IS
src_file BFILE;
dst_file BLOB;
lgh_file BINARY_INTEGER;
BEGIN
src_file := BFILENAME ('image_DIR', p_image_name);
-- insert a NULL record to lock
INSERT INTO program_images
(image_id, image_filename, image
)
VALUES (p_id, p_image_name, EMPTY_BLOB ()
)
RETURNING image
INTO dst_file;
-- lock record
SELECT image
INTO dst_file
FROM program_images
WHERE image_id = p_id AND image_filename = p_image_name
FOR UPDATE;
-- open the file
DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
-- determine length
lgh_file := DBMS_LOB.getlength (src_file);
-- read the file
DBMS_LOB.loadfromfile (dst_file, src_file, lgh_file);
-- update the blob field
UPDATE program_images
SET image = dst_file
WHERE image_id = p_id AND image_filename = p_image_name;
-- close file
DBMS_LOB.fileclose (src_file);
END insert_image_file;
然后制作所有图像所在的目录:
最终制作的程序,将图像插入表格:
EXECUTE insert_image_file(1,'audi_logo.png');
当我调用procedure _mm_loadu_si128
时,它在程序“DBMS_LOB.fileopen(src_file,DBMS_LOB.file_readonly);”中告诉我“FILEOPEN操作中不存在的目录或文件”。这条线。
这是我第一次使用目录,所以也许我忘记了要做的事情?
答案 0 :(得分:3)
图像目录名称应为UPPER_CASE,即
src_file := BFILENAME ('IMAGE_DIR', p_image_name);
The directory argument is case sensitive. You must ensure that you specify the
directory object name exactly as it exists in the data dictionary.