IBM Books

Image, Audio, and Video Extenders Administration and Programming

Updating an object with user-supplied attributes

When you update an image, audio, or video object that was stored with user-supplied attributes, you must specify the attributes of the updating content. Assign the attribute values in an attribute structure. The attribute structure must be stored in the data field of the LONG VARCHAR FOR BIT DATA variable in the UDF.

The UDF code on the server always expects data in "big endian format". Big endian format is a format used by most UNIX platforms. If you are storing an object in "little endian format", you need to prepare the user-supplied attribute data so that UDF code on the server can correctly process it. Little endian format is a format typically used in an Intel and other microprocessor platform. (Even if you are not storing the object in little endian format, it is a good idea to prepare the user-supplied attrubute data.) Use the DBiPrepareAttrs API to prepare attributes for image objects. Use the DBaPrepareAttrs API to prepare attributes for audio objects. Use the DBvPrepareAttrs API to prepare attributes for video objects.

For example, the following statements in a C application program update an image whose content is in a server file. The image has a user-defined format, a height of 640 pixels, and a width of 480 pixels. Notice that the attributes are prepared before the image is updated.

EXEC SQL BEGIN DECLARE SECTION;
  long hvStorageType;
struct {
       short len;
       char data[400];
       }hvImgattrs;
EXEC SQL END DECLARE SECTION;
 
DB2IMAGEATTRS    *pimgattr;
 
hvStorageType=MMDB_STORAGE_TYPE_INTERNAL;
 
pimgattr = (DB2IMAGEATTRS *) hvImgattrs.data;
strcpy(pimgattr>Format,"FormatI");
pimgattr>width=640;
pimgattr>height=480;
hvImgattrs.len=sizeof(DB2IMAGEATTRS);
 
DBiPrepareAttrs(pimgattr);
 
EXEC SQL UPDATE EMPLOYEE
   SET PICTURE=REPLACE(
                 PICTURE,
                 '/employee/newimg/ajones.bmp',
                 :hvStorageType,
                 'Anita''s new picture',
                 :ImgAttrs,                     /*user-supplied attributes*/
                 CAST(NULL as LONG VARCHAR))
   WHERE NAME='Anita Jones';


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