Image | Audio | Video |
---|---|---|
X |
Stores the content of an image in a database table. The image source can be in a client buffer, client file, or server file. The image can be stored in the database table as a BLOB, or in a server file (referred to by the database table). The image source can be in a supported format, in which case the DB2 Image Extender identifies its attributes for storage, or in an unsupported format, in which case the attributes must be specified in the UDF.
Include file
dmbimage.h
Syntax
Store content from buffer or client file
>>-DB2Image--(--dbname--,--content--,--source_format--,---------> >----target_file--,--comment--)--------------------------------><
Syntax
Store content from server file
>>-DB2Image--(--dbname--,--source_file--,--source_format--,-----> >----stortype--,--comment--)-----------------------------------><
Syntax
Store content with user-supplied attributes from buffer or client file
>>-DB2Image--(--dbname--,--content--,--target_file--,-----------> >----comment--,--attrs--,--thumbnail--)------------------------><
Syntax
Store content with user-supplied attributes from server file
>>-DB2Image--(--dbname--,--source_file--,--stortype--,--comment--,--> >---attrs--,--thumbnail--)-------------------------------------><
Syntax
Store content from buffer or client file with format conversion
>>-DB2Image--(--dbname--,--content--,--source_format--,---------> >----target_format--,--target_file--,--comment--)--------------><
Syntax
Store content from server file with format conversion
>>-DB2Image--(--dbname--,--source_file--,--source_format--,-----> >----target_format--,--target_file--,--comment--)--------------><
Syntax
Store content from buffer or client file with format conversion and additional changes
>>-DB2Image--(--dbname--,--content--,--source_format--,---------> >----target_format--,--conversion_options--,--target_file--,----> >----comment--)------------------------------------------------><
Syntax
Store content from server file with format conversion and additional changes
>>-DB2Image--(--dbname--,--source_file--,--source_format--,-----> >----target_format--,--conversion_options--,--target_file--,----> >----comment--)------------------------------------------------><
Parameters (data type)
Return values (data type)
Handle of the image (DB2IMAGE)
Examples
Insert a record that includes an image for Anita Jones into the employee table. The image source is in a client buffer. Store the image in the table as a BLOB:
EXEC SQL BEGIN DECLARE SECTION SQL TYPE IS BLOB (2M) hvImg EXEC SQL END DECLARE SECTION; EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2IMAGE( CURRENT SERVER, :hvImg, 'ASIS', CAST(NULL as LONG VARCHAR), 'Anita''s picture'));
Insert a record that includes an image for Robert Smith into the employee table. The image source is in a server file. The employee table record will point to the file. Convert the format of the image from BMP to GIF when stored. Also crop the image to a width of 110 pixels and a height of 150 pixels and compress the image by using LZW type compression:
EXEC SQL INSERT INTO EMPLOYEE VALUES( '384779', 'Robert Smith', DB2IMAGE( CURRENT SERVER, '/employee/pictures/rsmith.bmp', 'BMP', 'GIF', '-x 110 -y 150 -c 14', '', 'Robert"s picture'));
Insert a record that includes an image for Robert Smith into the employee table. The source image, which is in a server file, has a user-defined format, a height of 640 pixels, and a width of 480 pixels. Store the image as a BLOB:
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(pimgattrt>cFormat,"FormatI"); pimgattr>width=640; pimgattr>height=480; hvImgattrs.len=sizeof(DB2IMAGEATTRS); EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2IMAGE( CURRENT SERVER, '/employee/images/ajones.bmp', :hvStorageType, 'Anita''s picture', :hvImgattrs, CAST(NULL as LONG VARCHAR)) );