Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Large Objects
 

Loading a page to a BLOB

SQL> SQL> create table catalog   2  (id number,   3   name VARCHAR2(2000),   4   manual_cl CLOB,   5   firstpage_bl BLOB,   6   mastertxt_bf BFILE   7   ); Table created. SQL> SQL> create directory IO as 'C:\IO'; Directory created. SQL> --grant read, write on directory IO to public; SQL> SQL> insert into catalog(id, name, mastertxt_bf) values (1, 'TEXT.HTM', BFILENAME ('IO', 'text.htm')); 1 row created. SQL> SQL> declare   2      v_file_bf  BFILE:= BFILENAME ('IO','picture.gif');   3      v_firstpage_bl   BLOB;   4      src_offset_nr       NUMBER := 1;   5      dst_offset_nr       NUMBER := 1;   6  begin   7      update catalog set firstpage_bl = EMPTY_BLOB() where id = 1;   8   9      select firstpage_bl into v_firstpage_bl from catalog where id = 1;  10  11      DBMS_LOB.fileopen (v_file_bf, DBMS_LOB.file_readonly);  12      DBMS_LOB.loadblobfromfile (v_firstpage_bl, v_file_bf,  13                             DBMS_LOB.getlength (v_file_bf),  14                             dst_offset_nr, src_offset_nr);  15      DBMS_LOB.fileclose (v_file_bf);  16  end;  17  / declare * ERROR at line 1: ORA-22288: file or LOB operation FILEOPEN failed The system cannot find the path specified. ORA-06512: at "SYS.DBMS_LOB", line 523 ORA-06512: at line 11 SQL> SQL> drop directory IO; Directory dropped. SQL> drop table catalog; Table dropped.