Select into a var binary host variable
- Allocates memory for the data buffer of the var binary host
variable, vbin_image.
The ifx_var_flag() function with a flag value of 1 notifies IBM® Informix® ESQL/C that it is to allocate a new data buffer for the vbin_image host variable. (This data buffer had been deallocated after the INSERT statement completed.) Informix ESQL/C performs this allocation when it receives the data from the SELECT statement.
- Selects the data that the image_col opaque-type column
contains into the vbin_image data buffer.
When the database server executes the SELECT statement, it calls the send support function for image to perform any translation necessary between the internal format of the image data type on disk and the internal format that the Informix ESQL/C client application has sent (image_t).
- Stores the data that the data buffer of the vbin_image host
variable contains in an image_t structure.
After the SELECT statement, the data buffer of the vbin_image host variable contains data in the internal format of the image data type. The ifx_var_getdata() function returns the contents of this data buffer into an image_t data structure. Because the ifx_var_getdata() function returns the data buffer as a “void *” value, this call to ifx_var_getdata() casts this return value as a pointer to an image_t structure before it assigns it to the image_ptr variable.
- Unloads the image data from the image_t internal data structure
to an external JPEG, GIF, or PPM file.
The unload_image() routine unloads the user_image structure to an external file.
- Deallocates the data buffer of the vbin_image host variable.
The ifx_var_dealloc() function deallocates the vbin_image data buffer. You must explicitly deallocate the data buffer even when Informix ESQL/C allocated it for you.
- Check an indicator variable that is associated with a var binary host
variable for a value of -1. The following code fragment uses the image_ind indicator variable and the vbin_image host variable to check for a null value from the circle_col column:
#include <image.h>; EXEC SQL BEGIN DECLARE SECTION; var binary 'image' vbin_image; int image_ind; EXEC SQL END DECLARE SECTION; EXEC SQL select image_col into :vbin_image:image_ind from image_tab where image_id = 1; if (image_ind == -1) ⋮
- Use the ifx_var_isnull() function to check
the data buffer of the var binary host variable for a null
value. For the same vbin_image host variable, the following lines use the ifx_var_isnull() function to check for a null value in the image_col column:
EXEC SQL select image_col into :vbin_image from image_tab where image_id = 1; if (ifx_var_isnull(&vbin_image) == 1) ⋮