IBM Books

Image, Audio, and Video Extenders Administration and Programming

Content


Image Audio Video
X X X

Retrieves or updates the content of an image, audio, or video from a database. The content can be retrieved to a client buffer, client file, or server file.

Include file

image
dmbimage.h

audio
dmbaudio.h

video
dmbvideo.h

Syntax

Retrieve content to buffer or client file

>>-Content--(--handle--)---------------------------------------><
 

Syntax

Retrieve a segment of content to buffer or client file

>>-Content--(--handle--,--offset--,--size--)-------------------><
 

Syntax

Retrieve content to server file

>>-Content--(--handle--,--target_file--,--overwrite--)---------><
 

Syntax

Retrieve content to buffer or client file with format conversion--image only

>>-Content--(--handle--,--target_format--)---------------------><
 

Syntax

Retrieve content to server file with format conversion--image only

>>-Content--(--handle--,--target_file--,--overwrite--,---------->
 
>----target_format--)------------------------------------------><
 

Syntax

Retrieve content to buffer or client file with format conversion and additional changes--image only

>>-Content--(--handle--,--target_format--,--conversion_options--)-->
 
>--------------------------------------------------------------><
 

Syntax

Retrieve content to server file with format conversion and additional changes--image only

>>-Content--(--handle--,--target_file--,--overwrite--,---------->
 
>----target_format--,--conversion_options--)-------------------><
 

Syntax

Update content from buffer or client file

>>-Content--(--handle--,--content--,--source_format--,---------->
 
>----target_file--)--------------------------------------------><
 

Syntax

Update content from server file

>>-Content--(--handle--,--source_file--,--source_format--,------>
 
>----stortype--)-----------------------------------------------><
 

Syntax

Update content with user-supplied attributes from buffer or client file

>>-Content--(--handle--,--content--,---------------------------->
 
>----target_file--,--attrs--,--thumbnail--)--------------------><
 

Syntax

Update content with user-supplied attributes from server file

>>-Content--(--handle--,--source_file--,--stortype--,--attrs--,-->
 
>---thumbnail--)-----------------------------------------------><
 

Syntax

Update content from buffer or client file with format conversion--image only

>>-Content--(--handle--,--content--,--source_format--,---------->
 
>----target_format--,--target_file--)--------------------------><
 

Syntax

Update content from server file with format conversion--image only

>>-Content--(--handle--,--source_file--,--source_format--,------>
 
>----target_format--,--target_file--)--------------------------><
 

Syntax

Update content from buffer or client file with format conversion and additional changes--image only

>>-Content--(--handle--,--content--,--source_format--,---------->
 
>----target_format--,--conversion_options--,--target_file--)---><
 

Syntax

Update content from server file with format conversion and additional changes--image only

>>-Content--(--handle--,--source_file--,--source_format--,------>
 
>----target_format--,--conversion_options--,--target_file--)---><
 

Parameters (data type)

handle (DB2IMAGE, DB2AUDIO, or DB2VIDEO)
Column name or host variable that contains the handle of the image, audio, or video.

offset (INTEGER)
Starting offset (origin 1) of an image, audio, or video to be retrieved.

size (INTEGER)
Number of bytes of an image, audio, or video to be retrieved.

source_file (LONG VARCHAR)
The name of the file that contains the content for update of the image, audio, or video.

target_file (LONG VARCHAR)
For retrieval, the name of the file into which the image, audio, or video is to be retrieved. For update, the name of the file that contains the image, audio, or video to be updated.

stortype (INTEGER)
A value that indicates where the updated image, audio, or video will be stored. The constant MMDB_STORAGE_TYPE_INTERNAL (value=1) indicates that the updated object will be stored in the database as a BLOB. The constant MMDB_STORAGE_TYPE_EXTERNAL (value=0) indicates that the updated object will be stored in a server file.

overwrite (INTEGER)
A value that indicates whether to overwrite the target file if it already exists. The value can be 0 or 1. A value of 0 means the target file will not be overwritten (in effect, the retrieval will not take place). A value of 1 means the target file will be overwritten if the target file already exists.

target_format (VARCHAR(8))
The format of the image after retrieval or update. The format of the source image will be converted as appropriate. For retrieval of an image to a server file, if the target_file is the same as the source_file, the target format must be the same as the source format. For MPG1 format, you can specify MPG1, mpg1, MPEG1, or mpeg1. For MPG2 format, you can specify MPG2, mpg2, MPEG2, or mpeg2.

conversion_options (VARCHAR(100))
Specifies changes, such as rotation and compression, to be applied to the image when it is retrieved or updated. See Table 5 for the supported conversion options.

content (BLOB(2G) AS LOCATOR)
The host variable that contains the content for update of the image, audio, or video. The host variable can be of type BLOB, BLOB_FILE, or BLOB_LOCATOR. DB2 promotes the data type of the content to BLOB_LOCATOR and passes the LOB locator to the Content UDF.

source_format (VARCHAR(8))
The format of the source for update of the image, audio, or video. A null value or empty string can be specified, or for image only, the character string ASIS; in these three cases, the extender will attempt to determine the format automatically. For MPG1 format, you can specify MPG1, mpg1, MPEG1, or mpeg1. For MPG2 format, you can specify MPG2, mpg2, MPEG2, or mpeg2.

attrs (LONG VARCHAR FOR BIT)
The attributes of the image, audio, or video

thumbnail (LONG VARCHAR FOR BIT DATA)
A thumbnail of the image or video frame (image and video only)

Return values (data type)

The content of the retrieved image, audio, or video if retrieved to a buffer, (BLOB(2G) AS LOCATOR). If retrieved to a file, VARCHAR(254).

For update, the handle of the image, audio, or video to be updated (DB2IMAGE, DB2AUDIO, or DB2VIDEO).

Examples

Retrieve into a server file the image that is stored for Anita Jones in the picture column of the employee table:

struct{
      short len;
      char data[250];
      }hvImg_fname;
EXEC SQL END DECLARE SECTION;
 
EXEC SQL SELECT CONTENT (PICTURE,
       '/employee/images/ajones.bmp',1)
      INTO :hvImg_fname
      FROM EMPLOYEE
      WHERE NAME='Anita Jones';

Retrieve into a client buffer the 1-MB audio clip stored for Robert Smith in the sound column of the employee table:

EXEC SQL BEGIN DECLARE SECTION;
     SQL TYPE IS BLOB_LOCATOR audio_loc;
EXEC SQL END DECLARE SECTION;
 
EXEC SQL SELECT CONTENT (SOUND, 1, 1000000)
      INTO :audio_loc
      FROM EMPLOYEE
      WHERE NAME='Robert Smith';

Update Anita Jones's image in the picture column of the employee table; convert the format of the image from BMP to GIF and reduce the image to 50% of its original size:

EXEC SQL UPDATE EMPLOYEE
  SET picture = CONTENT(PICTURE,
       '/employee/newimg/ajones.bmp',
       'BMP',
       'GIF',
        '-s 0.5',
       '');
  WHERE NAME='Anita Jones';


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]