Insert smart large objects

When you use the INSERT statement to insert an object into a BLOB or CLOB column, the database server stores the object in an sbspace, rather than the table. The database server provides SQL functions that you can call from within an INSERT statement to import and export BLOB or CLOB data, otherwise known as smart large objects. For a description of these functions, see Smart large object functions.

The following INSERT statement uses the filetoblob() and filetoclob() functions to insert a row of the inmate table. (Create the inmate and fbi_list tables. defines the inmate table.)
INSERT INTO inmate
   VALUES (437, FILETOBLOB('datafile', 'client'), 
      FILETOCLOB('tmp/text', 'server'));
In the preceding example, the first argument for the FILETOBLOB() and FILETOCLOB() functions specifies the path of the source file to be copied into the BLOB and CLOB columns of the inmate table, respectively. The second argument for each function specifies whether the source file is located on the client computer ('client') or server computer ('server'). To specify the path of a file name in the function argument, apply the following rules:
  • If the source file resides on the server computer, you must specify the full path name to the file (not the path name relative to the current working directory).
  • If the source file resides on the client computer, you can specify either the full or relative path name to the file.
Note: For CLOB columns, direct strings can also be used in place of FILETOCLOB() function.