IBM Books

Image Extender、Audio Extender 和 Video Extender 管理和程序设计

DB2Image、DB2Audio 和 DB2Video UDF 格式

DB2Image、DB2Audio 和 DB2Video UDF 是重载的,即它们的格式随使用 UDF 的方法不同而有所不同。每个 UDF 都具有下列格式(格式中显示的 xxxxx 可以是 Image、Audio 或 Video):

格式 1:从客户机缓冲区或客户机文件存储对象:

DB2xxxxx(
     CURRENT SERVER,       /* database name name in CURRENT SERVER REGISTER */
     content,              /* object content */
     format,               /* source format */
     target_file,          /* target file name for storage in file server */
                           /* or NULL for storage in table as BLOB */
     comment               /* user comment */
  );

格式 2:从服务器文件存储对象:

DB2xxxxx(
     CURRENT SERVER,       /* database name in CURRENT SERVER REGISTER */
     source_file,          /* source file name */
     format,               /* source format */
     stortype,             /* MMDB_STORAGE_TYPE_EXTERNAL=store */
                           /* in file server*/
                           /* MMDB_STORAGE_TYPE_INTERNAL=store */
                           /* as a BLOB*/
     comment               /* user comment */
  );

格式 3:从客户机缓冲区或客户机文件存储具有用户提供的属性的对象:

DB2xxxxx(
     CURRENT SERVER,           /* database name in CURRENT SERVER REGISTER */
     content,                     /* object content */
     target_file,                 /* target file name for storage in file server */
                                  /* or NULL for storage in table as BLOB */
     comment,                     /* user comment */
     attrs,                       /* user-supplied attributes */
     thumbnail                    /* thumbnail (image and video only) */
  );

格式 4:存储服务器文件中具有用户提供的属性的对象:

DB2xxxxx(
     CURRENT SERVER,           /* database name in CURRENT SERVER REGISTER */
     source_file,              /* source file name */
     stortype,                 /* MMDB_STORAGE_TYPE_EXTERNAL=store */
                               /* in file server*/
                               /* MMDB_STORAGE_TYPE_INTERNAL=store */
                               /* as a BLOB*/
     comment,                  /* user comment */
     attrs,                    /* user-supplied attributes */
     thumbnail                 /* thumbnail (image and video only) */
  );

DB2Image UDF 包括下列附加格式:

格式 5: 从客户机缓冲区或客户机文件存储图象,并进行格式转换:

DB2Image(
     CURRENT SERVER,       /* database name in CURRENT SERVER REGISTER */
     content,              /* object content */
     source_format,        /* source format */
     target_format,        /* target format */
     target_file,          /* target file name for storage in file server */
                           /* or NULL for storage in table as BLOB */
     comment               /* user comment */
  );

格式 6: 从服务器文件存储图象,并进行格式转换:

DB2Image(
     CURRENT SERVER,       /* database name in CURRENT SERVER REGISTER */
     source_file,          /* server file name */
     source_format,        /* source format */
     target_format,        /* target format */
     target_file,          /* target file name for storage in file server */
                           /* or NULL for storage in table as BLOB */
     comment               /* user comment */
  );

格式 7: 从客户机缓冲区或客户机文件存储图象, 并进行格式转换和其他更改:

DB2Image(
     CURRENT SERVER,       /* database name in CURRENT SERVER REGISTER */
     content,              /* object content */
     source_format,        /* source format */
     target_format,        /* target format */
     conversion_options,   /* Conversion options */
     target_file,          /* target file name for storage in file server */
                           /* or NULL for storage in table as BLOB */
     comment               /* user comment */
  );

格式 8: 从服务器文件存储图象,并进行格式转换和其他更改:

DB2Image(
     CURRENT SERVER,       /* database name in CURRENT SERVER REGISTER */
     source_file,          /* server file name */
     source_format,        /* source format */
     target_format,        /* target format */
     conversion_options    /* conversion options */
     target_file,          /* target file name for storage in file server */
                           /* or NULL for storage in table as BLOB */
     comment               /* user comment */
  );

例如,C 应用程序中的下列语句将包括图象的行插入到 Employee 表中。源图象在名为 ajones.bmp 的服务器文件中。图象以 BLOB 形式存储在 Employee 表中。(这与上面的格式 2 相对应。)

EXEC SQL BEGIN DECLARE SECTION;
  long hvStorageType;
EXEC SQL END DECLARE SECTION;
 
hvStorageType=MMDB_STORAGE_TYPE_INTERNAL;
 
EXEC SQL INSERT INTO EMPLOYEE VALUES(
        '128557',                          /*id*/
        'Anita Jones',                     /*name*/
        DB2IMAGE(                          /*Image Extender UDF*/
          CURRENT SERVER,                  /*database*/
          '/employee/images/ajones.bmp',   /*source file */
          'ASIS',                          /*keep the image format*/
          :hvStorageType                   /*store image in DB as BLOB*/
          'Anita''s picture')              /*comment */
       );

C 应用程序中的下列语句象前一示例那样将同一行存储在 Employee 表中。但是此处, 在存储时将图象由 BMP 转换为 GIF 格式。(这与上面的格式 6 相对应。)

EXEC SQL INSERT INTO EMPLOYEE VALUES(
        '128557',                          /*id*/
        'Anita Jones',                     /*name*/
        DB2IMAGE(                          /*Image Extender UDF*
          CURRENT SERVER,                  /*database*/
          '/employee/images/ajones.bmp',   /*source file */
          'ASIS',                          /*source image format*/
          'GIF',                           /*target image format*/
          'Anita''s picture')              /*comment*/
       );

当存储图象、音频或视频对象时,Extender 计算诸如图象中使用的颜色数、 音频播放时间或视频压缩格式之类的属性。若存储了具有不可识别的格式的对象, 则需要提供这些属性以作为 UDF 的输入。Extender 将这些属性与其他属性(如关于对象的注解和存储该对象的用户的标识) 一起存储在数据库中。您在以后可以在查询中使用这些属性。


[ 页的顶部 | 上一页 | 下一页 | 目录 | 索引 ]