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 アプリケーションの次のステートメントでは、画像を含む行を従業員表に挿入します。 ソース画像は、ajones.bmp という名前のサーバー・ファイルにあります。 画像は従業員表に BLOB として保管されます。 (これは上の形式 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 アプリケーションの次のステートメントでは、前の例と同じ行を従業員表に挿入します。 しかしこの場合には、画像を保管する際に、形式を 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*/ );
画像、音声、ビデオのオブジェクトを保管すると、その画像で使用されている色数、音声の再生時間、ビデオの圧縮形式などの属性をエクステンダーが計算します。 形式が認識できないオブジェクトを保管する場合には、UDF への入力としてこれらの属性を指定する必要があります。 エクステンダーは、それらの属性を他の属性 (オブジェクトの注釈やオブジェクトを保管したユーザーの識別子など) とともにデータベースに保管します。 これらの属性は照会で使用することができます。