DECLARE x_blob BLOB; fils BFILE := BFILENAME ('IN_FILE_LOC', 'G74822LRs.pdf'); blob_length INTEGER; BEGIN -- Obtain the size of the blob file DBMS_LOB.fileopen (fils, DBMS_LOB.file_readonly); blob_length := DBMS_LOB.getlength (fils); DBMS_LOB.fileclose (fils); -- Insert a new record into the table containing the -- filename you have specified and a LOB LOCATOR. -- Return the LOB LOCATOR and assign it to x_blob. INSERT INTO test_files (pl_id,pl_name,pl_pict) VALUES (4, 'G74822LRs.pdf', EMPTY_BLOB ()) RETURNING pl_pict INTO x_blob; -- Load the file into the database as a BLOB DBMS_LOB.OPEN (fils, DBMS_LOB.lob_readonly); DBMS_LOB.OPEN (x_blob, DBMS_LOB.lob_readwrite); DBMS_LOB.loadfromfile (x_blob, fils, blob_length); -- Close handles to blob and file DBMS_LOB.CLOSE (x_blob); DBMS_LOB.CLOSE (fils); COMMIT; -- Confirm insert by querying the database -- for LOB length information and output results blob_length := 0; SELECT DBMS_LOB.getlength (pl_pict) INTO blob_length FROM test_files WHERE pl_name = 'G74822LRs.pdf'; DBMS_OUTPUT.put_line ('Successfully inserted BLOB ''' ||'G74822LRs.pdf' || ''' of size ' || blob_length || ' bytes.'); END;