Use a host variable or a file reference variable to transmit the contents of an image, audio, or video object from a client buffer or client file to the server.
If the object is in a client file, use a file reference variable to transmit its content for storage in the server. For example, the following statements in a C application program define a file reference variable named Audio_file and use it to transmit an audio clip whose content is in a client file. The audio clip is stored in a database table on the server. Notice that the file_option field of the file reference variable is set to SQL_FILE_READ for input. Also notice that the file reference variable is used as the content argument to the DB2Audio UDF.
EXEC SQL BEGIN DECLARE SECTION; SQL TYPE IS BLOB_FILE Audio_file; EXEC SQL END DECLARE SECTION; strcpy (Audio_file.name, "/employee/sounds/ajones.wav"); Audio_file.name_length= strlen(Audio_file.name); Audio_file.file_options= SQL_FILE_READ; EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2AUDIO( CURRENT SERVER, :Audio_file, /* file reference variable */ 'WAVE', CAST(NULL as LONG VARCHAR), 'Anita''s voice') );
If the object is in a client buffer, use a host variable, defined as either BLOB or BLOB_LOCATOR, to transmit its content for storage in the server. In the following C application program statements, a host variable named Video_loc is used to transmit the contents of a video clip for storage in the server. 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 DB2Video UDF.
EXEC SQL BEGIN DECLARE SECTION; SQL TYPE IS BLOB_LOCATOR Video_loc; EXEC SQL END DECLARE SECTION; EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2VIDEO( CURRENT SERVER, :Video_loc, /* host variable */ 'MPEG1', '', 'Anita''s video') );
Make sure that you have enough UDF memory: When you store 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 4 MB or greater. You can update the UDF_MEM_SZ parameter by using the DB2 command UPDATE DATABASE MANAGER CONFIGURATION.
For more information on the UPDATE DATABASE MANAGER command, see the DB2 Command Reference.