Example: Inserting data into a CLOB column

This example shows how to insert data from a regular file referenced by :hv_text_file into a character large object (CLOB) column.

In the path description of the following C program segment:

  • userid represents the directory for one of your users.
  • dirname represents a subdirectory name of userid.
  • filnam.1 can become the name of one of your documents that you want to insert into the table.
  • clobtab is the name of the table with the CLOB data type.
     strcpy(hv_text_file.name, "/home/userid/dirname/filnam.1"); 
     hv_text_file.name_length = strlen("/home/userid/dirname/filnam.1"); 
     hv_text_file.file_options = SQL_FILE_READ; /* this is a 'regular' file */ 
  
     EXEC SQL INSERT INTO CLOBTAB 
       VALUES(:hv_text_file);