Read/write operations for oracle blob -- create or replace procedure P_IMG_INSERT (v_filename VARCHAR2) IS www.2cto.com v_bfile BFILE; -- file pointer v_blob blob; dir constant VARCHAR2 (20 ): = 'test'; -- DIRECTORY for storing files, case sensitive V_DEST NUMBER: = 1; V_LANG NUMBER: = 1; BEGIN/* through empty_blob () the function initializes blob-type columns to be empty for future filling */insert into res_info (res_blob) VALUES (EMPTY_BLOB () RETURN res_blob INTO v_blob; v_bfile: = BFILENAME (DIR, v_file Name); IF (dbms_lob.fileexists (v_bfile )! = 0) THEN dbms_lob.fileopen (v_bfile, dbms_lob.file_readonly); -- open the target file/* load the file data to the specified LOB type variable */empty (v_blob, www.2cto.com v_bfile, dbms_lob.getlength (v_bfile), V_DEST, V_LANG); -- dbms_lob.loadblobfromfile dbms_lob.fileclose (v_bfile); -- close the file COMMIT; dbms_output.put_line ('file read from' | DIR | 'directory' | v_filename | 'insert to table '); ELSE -- IF the file pointed to by the file locator does not exist dbms_output.put_line ('file not found '); end if; exception when others then dbms_output.put_line (SQLERRM); END; www.2cto.com: round (dest_lob in out nocopy blob, src_bfile in bfile, amount in integer, dest_offset in out integer, src_offset in out integer); www.2cto.com Parameter Descriptiondest_lob BLOB locator of the target for the load. src_bfile BFILE locator of the source for the load. amount Number of bytes to load from the BFILE. you can also use DBMS_LOB.LOBMAXSIZE to load until the end of the BFILE. dest_offset (IN) Offset in bytbes in the destination BLOB (origin: 1) for the start of the write. (OUT) New offset in bytes in the destination BLOB right after the end of this write, which is also where the next write shoshould begin. src_offset (IN) Offset in bytes in the source BFILE (origin: 1) for the start of the read. (OUT) Offset in bytes in the source BFILE right after the end of this read, which is also where the next read shold begin. author chen11-1