Use a host variable or a file reference variable to update an image, audio, or video object from a client buffer or client file.
If the source for the update is in a client file, use a file reference variable to transmit its content. For example, the following statements in a C application program define a file reference variable named Audio_file and use it to update an audio clip stored in a database table as a BLOB. The source for the update is in a client file. Notice that the file_options field of the file reference variable is set to SQL_FILE_READ, that is, for input. Also notice that the file reference variable is used as the content argument to the Content UDF.
EXEC SQL BEGIN DECLARE SECTION; SQL TYPE IS BLOB_FILE Audio_file; EXEC SQL END DECLARE SECTION; strcpy (Audio_file.name, "/employee/newsound/ajones.wav"); Audio_file.name_length= strlen(Audio_file.name); Audio_file.file_options= SQL_FILE_READ; EXEC SQL UPDATE EMPLOYEE SET SOUND=CONTENT( SOUND, :Audio_file /*file reference variable*/ 'WAVE', /*keep the image format*/ CAST(NULL as LONG VARCHAR)) WHERE NAME='Anita Jones';
If the object is in a client buffer, use a host variable to transmit its content for update. In the following C application program example, a host variable named Video_seg is used to transmit the contents of a video clip for update. The comment associated with the video clip is also updated. The video clip is stored in a database table as a BLOB. Notice that the host variable is used as the content argument to the Replace UDF.
EXEC SQL BEGIN DECLARE SECTION; SQL TYPE IS BLOB (2M) Video_seg EXEC SQL END DECLARE SECTION; EXEC SQL UPDATE EMPLOYEE SET VIDEO=REPLACE( VIDEO, :Video_seg /*host variable*/ 'MPEG1', CAST(NULL as LONG VARCHAR), 'Anita''s new video') WHERE NAME='Anita Jones';
Make sure that you have enough UDF memory: When you update an object whose content is in a client buffer, you need to make sure that the UDF_MEM_SZ parameter in the Database Manager Configuration is set to 4MB or greater. You can update the UDF_MEM_SZ parameter with the DB2 command UPDATE DATABASE MANAGER CONFIGURATION.