Loading a page to a BLOB : BLOB « Large Objects « Oracle PL/SQL Tutorial






SQL>
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>
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>
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.








34.3.BLOB
34.3.1.Creating Tables Containing BLOB Objects
34.3.2.Initialize BLOB column data
34.3.3.Adding Content to a BLOB
34.3.4.Use update statement to change the value in blob type column
34.3.5.UPDATE sets blob_column to a binary number:
34.3.6.Open the BLOB
34.3.7.Loading a page to a BLOB
34.3.8.Populating a BLOB column from an external BFILE
34.3.9.INSERT a row with an empty blob
34.3.10.Display the length of the BLOB
34.3.11.Obtain length of the populated BLOB
34.3.12.Close the BLOB