pdf file saved in database [message #689817] |
Fri, 03 May 2024 23:42 |
narang79
Messages: 137 Registered: June 2010
|
Senior Member |
|
|
Hi
I want to save pdf file in my oracle database 11.2.0.4 . It is working fine but when i saved through network then it create error
it working fine when running from database server but it gives error when run this program through network
CREATE DIRECTORY res_upload1 AS '\\192.15.200.212\C:\D\share\New';
GRANT READ, WRITE ON DIRECTORY res_upload1 TO hris;
Grant all on directory res_upload1 to hris;
DECLARE
l_bfile BFILE;
l_blob BLOB;
l_blob_length NUMBER;
BEGIN
-- Open the PDF file
l_bfile := BFILENAME('RES_UPLOAD1', 'new.pdf');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
-- Get the length of the file
l_blob_length := DBMS_LOB.getlength(l_bfile);
-- Create an empty BLOB
DBMS_LOB.createtemporary(l_blob, TRUE);
-- Load the file into the BLOB
DBMS_LOB.loadfromfile(l_blob, l_bfile, l_blob_length);
-- Insert the BLOB into the table
INSERT INTO hris.pdf_files (id, file_name, file_data) VALUES (2, 'new.pdf', l_blob);
-- Close the file and free the BLOB
DBMS_LOB.fileclose(l_bfile);
DBMS_LOB.freetemporary(l_blob);
END;
ORA-22288: file or LOB operation FILEOPEN failed. Filename
|
|
|
|
Re: pdf file saved in database [message #689820 is a reply to message #689819] |
Mon, 06 May 2024 05:28 |
narang79
Messages: 137 Registered: June 2010
|
Senior Member |
|
|
trying with the suggest code but same error occured
CREATE DIRECTORY res_upload1 AS '\\192.15.200.212\C$\D\share\New';
GRANT READ, WRITE ON DIRECTORY res_upload1 TO hris;
Grant all on directory res_upload1 to hris;
DECLARE
l_bfile BFILE;
l_blob BLOB;
l_blob_length NUMBER;
BEGIN
-- Open the PDF file
l_bfile := BFILENAME('RES_UPLOAD1', 'new.pdf');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
-- Get the length of the file
l_blob_length := DBMS_LOB.getlength(l_bfile);
-- Create an empty BLOB
DBMS_LOB.createtemporary(l_blob, TRUE);
-- Load the file into the BLOB
DBMS_LOB.loadfromfile(l_blob, l_bfile, l_blob_length);
-- Insert the BLOB into the table
INSERT INTO hris.pdf_files (id, file_name, file_data) VALUES (2, 'new.pdf', l_blob);
-- Close the file and free the BLOB
DBMS_LOB.fileclose(l_bfile);
DBMS_LOB.freetemporary(l_blob);
END;
ORA-22288: file or LOB operation FILEOPEN failed. No such file or directory
|
|
|