IBM Books

Image, Audio, Video Extender °ü¸® ¹× ÇÁ·Î±×·¡¹Ö


DB2 Extender¿ë ÇÁ·Î±×·¡¹ÖÀ» ½ÃÀÛÇϱâ Àü¿¡

DB2 Extender¸¦ »ç¿ëÇÏ´Â ÇÁ·Î±×·¥À» °³¹ßÇÏ·Á¸é, DB2 ÀÀ¿ëÇÁ·Î±×·¥ °³¹ß ¾È³»¼­¿¡ ¼³¸íµÈ ´ë·Î DB2 ÀÀ¿ëÇÁ·Î±×·¥ °³¹ß ÇÁ·Î¼¼½º¿Í ÇÁ·Î±×·¡¹Ö ±â¹ý¿¡ Ä£¼÷ÇØ¾ß ÇÕ´Ï´Ù. DB2 Extender¸¦ »ç¿ëÇÏ´Â ÇÁ·Î±×·¥ °³¹ß¿ë ÇÁ·Î¼¼½º´Â ÀüÅëÀûÀÎ DB2 ÀÀ¿ëÇÁ·Î±×·¥¿ë ÇÁ·Î¼¼½º¿Í º»ÁúÀûÀ¸·Î µ¿ÀÏÇÕ´Ï´Ù.

ÀÀ¿ëÇÁ·Î±×·¥ ÄÚµå´Â ÀüÅëÀûÀÎ DB2 ÀÀ¿ëÇÁ·Î±×·¥°ú´Â ´Ù¸¥µ¥, ±×°ÍÀº Extender°¡ Á¤ÀÇÇÑ »õ·Î¿î µ¥ÀÌÅÍ À¯Çü°ú ÇÔ¼ö ¶§¹®ÀÔ´Ï´Ù. ¿¹¸¦ µé¾î, ´Â´ÙÀ½ ±×¸²Àº µ¥ÀÌÅͺ£À̽º Å×ÀÌºí¿¡ ÀúÀåµÈ GIF À̹ÌÁö¸¦ ½Äº°Çϱâ À§ÇØ Image Extender¸¦ »ç¿ëÇÏ´Â C·Î ÄÚµùµÈ ÀÀ¿ëÇÁ·Î±×·¥À» ³ªÅ¸³À´Ï´Ù. À̹ÌÁö ½Äº° ÈÄ, ÇÁ·Î±×·¥Àº À̹ÌÁö¸¦ ³ªÅ¸³»±â À§ÇØ À̹ÌÁö ºê¶ó¿ìÀú¸¦ È£ÃâÇÕ´Ï´Ù.

¿¹½Ã¿¡¼­ ¼³¸íÇÏ´Â °Íó·³, DB2 Extender¸¦ »ç¿ëÇÏ´Â ÀÀ¿ëÇÁ·Î±×·¥Àº ´ÙÀ½ ±â´ÉÀ» ¼öÇàÇØ¾ß ÇÕ´Ï´Ù.

(1)Extender Á¤ÀǸ¦ Æ÷ÇÔÇϽʽÿÀ. ¿¹½ÃÀÇ dmbimage.h ÆÄÀÏÀº Image Extender¿ë Include(Çì´õ) ÆÄÀÏÀÔ´Ï´Ù. Include ÆÄÀÏÀº Extender¿ë »ó¼ö, º¯¼ö ¹× ÇÔ¼ö ÇÁ·ÎÅäŸÀÔÀ» Á¤ÀÇÇÕ´Ï´Ù.

(2)UDF¿¡¼­ÀÇ ÀÔÃâ·Â ¶Ç´Â API È£Ãâ·ÎÀÇ ÀÔ·ÂÀ» Æ÷ÇÔÇϱâ À§ÇØ ÇÊ¿äÇÑ È£½ºÆ® º¯¼ö¸¦ Á¤ÀÇÇϽʽÿÀ. ¿¹½Ã¿¡¼­, hvFormat, hvSize, hvWidth, hvHeight ¹× hvComment´Â Image Extender UDF°¡ °Ë»öÇÏ´Â µ¥ÀÌÅ͸¦ Æ÷ÇÔÇÏ´Â µ¥ »ç¿ëµÇ´Â È£½ºÆ® º¯¼öÀÔ´Ï´Ù. È£½ºÆ® º¯¼ö hvImg_hdlÀº Image Extender API È£Ãâ¿¡ ´ëÇÑ ÀÔ·ÂÀ¸·Î ÁöÁ¤µÈ À̹ÌÁö ÇÚµéÀ» Æ÷ÇÔÇϱâ À§ÇØ »ç¿ëµË´Ï´Ù.

(3)UDF ¿äûÀ» ÇÊ¿äÇÑ ´ë·Î ÁöÁ¤ÇϽʽÿÀ. ¿¹½Ã¿¡¼­, SIZE, WIDTH, HEIGHT, COMMENT ¹× FORMATÀº Image Extender UDFÀÔ´Ï´Ù.

(4)API È£ÃâÀ» ÇÊ¿äÇÑ ´ë·Î ÁöÁ¤ÇϽʽÿÀ. ¿¹½Ã¿¡¼­, DBiBrowse´Â Å×ÀÌºí¿¡¼­ °Ë»öµÇ´Â ÇÚµéÀÇ À̹ÌÁö¸¦ Ç¥½ÃÇÏ´Â ±¹Áö C ÇÔ¼ö·ÎÀÇ API È£ÃâÀÔ´Ï´Ù.

±×¸² 18. DB2 Extender¸¦ »ç¿ëÇÏ´Â ÀÀ¿ëÇÁ·Î±×·¥

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include <sqlcodes.h>
#include <dmbimage.h> (1)
 
int count=0;
 
long
main(int argc,char *argv[])
{
EXEC SQL BEGIN DECLARE SECTION; (2)
         char hvImg_hdl[251];                   /* image handle */
         char hvDBName[19];                     /* database name */
         char hvName[40];                       /* employee name */
         char hvFormat[9];                      /* image format */
         long hvSize;                           /* image size */
         long hvWidth;                          /* image width */
         long hvHeight;                         /* image height */
         struct  {
                  short len;
                  char data[32700]
         } hvComment;                           /* comment about the image */
 EXEC SQL END DECLARE SECTION;
 
/*  Connect to database  */
 
strcpy(hvDBName, argv[1]);                      /* copy the database name */
 
EXEC SQL CONNECT TO :hvDBName IN SHARE MODE;
/*
 * Set current function path
*/
EXEC SQL SET CURRENT FUNCTION PATH = mmdbsys, CURRENT FUNCTION PATH;
/*
 * Select (query) using Image Extender UDF
 *
 * The SQL statement below finds all images in GIF format.
 */
EXEC SQL DECLARE c1 CURSOR FOR
         SELECT PICTURE, NAME,                (3)
                SIZE(PICTURE), WIDTH(PICTURE),
                HEIGHT(PICTURE), COMMENT(PICTURE)
         FROM EMPLOYEE
         WHERE PICTURE IS NOT NULL AND
               FORMAT(PICTURE) LIKE 'GIF%'
FOR FETCH ONLY;
 
EXEC SQL OPEN c1;
for (;;) {
         EXEC SQL FETCH c1 INTO :hvImg_hdl, :hvName, :hvSize,
                                :hvWidth, :hvHeight, :hvComment
;
         if (SQLCODE != 0)
                   break;
 
         printf("\nRecord %d:\n", ++count);
         printf("employee name = '%s'\n", hvName);
         printf("image size = %d bytes, width=%d, height=%d\n",
                                                 hvSize, hvWidth, hvHeight);
         hvComment.data[Comment.len]='\0';
         printf("comment len = %d\n", hvComment.len);
 printf("comment = %s\n", hvComment.data);
/*
* The API call below displays the images
*/
(4) rc=DBiBrowse ("ib %s",MMDB_PLAY_HANDLE,hvImg_hdl,
                         MMDB_PLAY_WAIT);
}
 
EXEC SQL CLOSE c1;
 
/* end of program */


[ ÆäÀÌÁöÀÇ ¸Ç À§ | ÀÌÀü ÆäÀÌÁö | ´ÙÀ½ ÆäÀÌÁö | ¸ñÂ÷ | »öÀÎ ]