Friday, 28 September 2018

Script to Load file from Directory to Blob column


create or replace PROCEDURE load_file(
    pi_id  IN INTEGER,
    pfname IN VARCHAR2)
IS
  SRC_FILE bfile;
  dst_file BLOB:= EMPTY_BLOB();
  lgh_file BINARY_INTEGER;
BEGIN
  src_file := bfilename('dir', pfname);
  INSERT
  INTO image_store
    (id_pk,fname,image)
    VALUES
    (pi_id,pfname,EMPTY_BLOB())
  RETURNING image
  INTO dst_file;
  DBMS_LOB.OPEN(src_file, dbms_lob.file_readonly);
  lgh_file := dbms_lob.getlength(src_file);
  DBMS_LOB.LOADFROMFILE(DST_FILE, SRC_FILE, LGH_FILE);
  --DBMS_LOB.FREETEMPORARY(dst_file);-- ADDED BY RAJAN
  COMMIT;
  dbms_lob.close(src_file);
END load_file;

6 comments:

  1. Magnificent blog I visit this blog it's extremely wonderful. Interestingly, in this blog content composed plainly and reasonable. The substance of data is useful.
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    Oracle Fusion Financials Online Training
    Big Data and Hadoop Training In Hyderabad

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information.

    Oracle Fusion Financials Online Training

    ReplyDelete
  4. Nice information. Thanks for sharing such an amazing article. For online training and Self Paced courses visit our site click4learning.com/

    ReplyDelete
  5. https://www.meghakhan.com/
    https://www.meghakhan.com/about.html

    ReplyDelete