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 具有下列附加的格式:
格式 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 (Audio Extender 不支援格式轉換)。它對應於上述格式 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 */