Replace UDF は多重定義されます。 つまり、UDF の使用方法に応じて異なる形式を持ちます。 形式は次のとおりです。
形式 1: クライアント・バッファーまたはクライアント・ファイルからのオブジェクトを更新し、その注釈を更新する。
Replace( handle, /* object handle */ content, /* object content */ source_format, /* source format */ target_file, /* target file name for storage in file */ comment /* user comment */ );
形式 2: サーバー・ファイルからのオブジェクトを更新し、その注釈を更新する。
Replace( handle, /* object handle */ source_file, /* server file name */ source_format, /* source format */ stortype, /* MMDB_STORAGE_TYPE_EXTERNAL=store */ /* in file server*/ /* MMDB_STORAGE_TYPE_INTERNAL=store as a BLOB*/ comment /* user comment */ );
形式 3: ユーザー提供の属性をもつオブジェクトをクライアント・バッファーまたはクライアント・ファイルから置換する。
Replace( handle, /* object handle */ content, /* object content */ target_file, /* target file name for storage in file */ /* or NULL for storage in table as BLOB */ comment, /* user comment */ attrs, /* user-supplied attributes */ thumbnail /* thumbnail */ );
形式 4: ユーザー提供の属性をもつオブジェクトをサーバー・ファイルから保管する。
Replace( handle, /* object handle */ source_file, /* server 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 */ );
画像オブジェクトでは、Replace UDF はさらに 2 つの形式をとります。
形式 5: クライアント・バッファーまたはクライアント・ファイルからの画像は、以下のように形式変換して更新し、注釈を更新する。
Replace( handle, /* object handle */ 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: サーバー・ファイルからのオブジェクトは、以下のように形式変換して更新し、注釈を更新する。
Replace( handle, /* object handle */ source_file, /* server file name */ source_format, /* source format */ target_format, /* target format */ target_file, /* MMDB_STORAGE_TYPE_EXTERNAL=store */ /* in file server */ /* MMDB_STORAGE_TYPE_INTERNAL=store as a BLOB*/ comment /* user comment */ );
形式 7: クライアント・バッファーまたはクライアント・ファイルからの画像は、以下のように形式変換および追加の変更をして更新し、注釈を更新する。
Replace( handle, /* object handle */ 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: サーバー・ファイルからのオブジェクトを形式変換して更新し、追加の変更を行い、注釈を更新する。
Replace( handle, /* object handle */ source_file, /* server file name */ source_format, /* source format */ target_format, /* target format */ conversion_options, /* conversion options */ target_file, /* MMDB_STORAGE_TYPE_EXTERNAL=store */ /* in file server */ /* MMDB_STORAGE_TYPE_INTERNAL=store as a BLOB*/ comment /* user comment */ );
たとえば、C アプリケーションの次のステートメントでは、従業員表の音声クリップを更新し、それに対応する注釈を更新します。 この更新のソースの内容は ajones.wav という名前のサーバー・ファイルにあります。 更新された音声クリップは、形式変換されずに従業員表に BLOB として保管されます (オーディオ・エクステンダーは形式変換をサポートしません)。 これは上の形式 2 に対応します。
EXEC SQL BEGIN DECLARE SECTION; long hvStorageType; EXEC SQL END DECLARE SECTION; hvStorageType=MMDB_STORAGE_TYPE_INTERNAL; EXEC SQL UPDATE EMPLOYEE SET SOUND=REPLACE( SOUND, /*audio handle*/ '/employee/newaud/ajones.wav', /*source file */ 'WAV', /*keep the audio format*/ :hvStorageType, /*store audio in DB as BLOB*/ 'Anita''s new greeting') /*user comment*/ WHERE NAME= 'Anita Jones';
次の例では、画像とそれに対応する注釈が更新されます。 この更新のソース内容はサーバー・ファイルにあります。 更新された画像は従業員表に BLOB として保管され、更新の際、その形式が BMP から GIF に変換されます。 (これは上の形式 6 に対応します。)
EXEC SQL UPDATE EMPLOYEE SET PICTURE=REPLACE( PICTURE, /*image handle*/ '/employee/newimg/ajones.bmp', /*source file */ 'BMP', /*source format*/ 'GIF', /*target format*/ '' /*store image in DB as BLOB*/ 'Anita''s new picture') WHERE NAME='Anita Jones'; /* user comment */