Home » Developer & Programmer » Forms » pdf file saved in database
pdf file saved in database [message #689817] Fri, 03 May 2024 23:42 Go to next message
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 #689819 is a reply to message #689817] Mon, 06 May 2024 02:55 Go to previous messageGo to next message
Littlefoot
Messages: 21809
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Path looks strange; shouldn't it be

\\192.15.200.212\C$\D\share\New

instead of

\\192.15.200.212\C:\D\share\New

(presuming that it is a folder named D\share\New that resides on the C drive)?
Re: pdf file saved in database [message #689820 is a reply to message #689819] Mon, 06 May 2024 05:28 Go to previous message
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
Previous Topic: header data block is not saved when update in details block
Next Topic: Problem calling a report from that have a chart
Goto Forum:
  


Current Time: Sat May 18 12:06:33 CDT 2024