The Content UDF is overloaded, meaning, that it has different formats depending on how the UDF is used. The formats are as follows:
Format 1: Retrieve an object to a client buffer or client file:
Content( handle, /* object handle */ );
Format 2: Retrieve a segment of an object to a client buffer or client file:
Content( handle, /* object handle */ offset, /* offset where retrieval begins */ size /* number of bytes to retrieve */ );
Format 3: Retrieve an object to a server file:
Content( handle, /* object handle */ target_file, /* server file name */ overwrite /* 0=Do not overwrite target file if it exists */ /* 1=Overwrite target file */ );
In addition, the Content UDF includes the following formats for image objects only:
Format 4: Retrieve an image to a client buffer or file with format conversion:
Content( handle, /* object handle */ target format /* target format */ );
Format 5: Retrieve an object to a server file with format conversion:
Content( handle, /* object handle */ target_file, /* server file name */ overwrite, /* 0=Do not overwrite target file if it exists */ /* 1=Overwrite target file */ target format /* target format */ );
Format 6: Retrieve an object to a client buffer or file with format conversion and additional changes:
Content( handle, /* object handle */ target format, /* target format */ conversion_options /* conversion options */ );
Format 7: Retrieve an object to a server file with format conversion and additional changes:
Content( handle, /* object handle */ target_file, /* server file name */ overwrite, /* 0=Do not overwrite target file if it exists */ /* 1=Overwrite target file */ target format, /* target format */ conversion_options /* conversion options */ );
For example, the following statement retrieves an image from the employee table to a file on the server. (This corresponds to format 3.)
EXEC SQL SELECT CONTENT( /* retrieval UDF */ PICTURE, /* image handle */ '/employee/images/ajones.bmp', /* target file */ 1) /* overwrite target file */ FROM EMPLOYEE WHERE NAME = 'Anita Jones';
The following statements in a C application program retrieve an image from the employee table to a file on the server. The format of the image is converted when it is retrieved. (This corresponds to format 5.)
EXEC SQL BEGIN DECLARE SECTION; char hvImg_fname[255]; EXEC SQL END DECLARE SECTION; EXEC SQL SELECT CONTENT( /* retrieval UDF */ PICTURE, /* image handle */ '/employee/images/ajones.bmp', /* target file */ 1, /* overwrite target file */ 'GIF') /* target format */ INTO :hvImg_fname FROM EMPLOYEE WHERE NAME = 'Anita Jones';