The Replace UDF is overloaded, that is, it has different formats depending on how the UDF is used. The formats are as follows:
Format 1: Update an object from a client buffer or client file and update its comment:
Replace( handle, /* object handle */ content, /* object content */ source_format, /* source format */ target_file, /* target file name for storage in file */ comment /* user comment */ );
Format 2: Update an object from a server file and update its comment:
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 */ );
Format 3: Replace an object with user-supplied attributes from a client buffer or client file and update its comment:
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 */ );
Format 4: Store an object with user-supplied attributes from a server file:
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 */ );
For image objects only, the Replace UDF has the following additional formats:
Format 5: Update an image from a client buffer or client file with format conversion and update its comment:
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 */ );
Format 6: Update an object from a server file with format conversion and update its comment:
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 */ );
Format 7: Update an image from a client buffer or client file with format conversion and additional changes and update its comment:
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 */ );
Format 8: Update an object from a server file with format conversion and additional changes and update its comment:
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 */ );
For example, the following statements in a C application program update an audio clip in the employee table and update its associated comment. The source content for the update is in a server file that is named ajones.wav. The updated audio clip is stored in the employee table as a BLOB without format conversion (the Audio Extender does not support format conversion). This corresponds to format 2 above.
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';
In the following example an image and its associated comment are updated. The source content for the update is in a server file. The updated image is stored in the employee table as a BLOB, and is converted from BMP to GIF format on update. (This corresponds to format 6 above.)
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 */