title: Add images to Oracle Database
body: <p>Hello I am trying to add images to table.
  I made table:</p>
  
  <pre><code>    CREATE TABLE program_images
   (
   image_id NUMBER,
   image_filename VARCHAR2(50),
   image BLOB
   );
  </code></pre>
  
  <p>Then made directory where All images are: 
  <img src="https://i.stack.imgur.com/L44ol.png" alt="enter image description here"></p>
  
  <p>Finaly made procedure, which insert images to table: </p>
  
  <pre><code>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;
  </code></pre>
  
  <p>Is that when I call procedure: <code>EXECUTE insert_image_file(1,'audi_logo.png');</code> it says me that "non-existent directory or file for FILEOPEN operation" in procedure what is "   DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);" this line.
  It was first time I use directories, so maybe I forget something to do? </p>