User-defined simple-large-object locations

You can create your own versions of the loc_open(), loc_read(), loc_write(), and loc_close() functions to define your own location for simple-large-object data.

A typical use for user-defined location functions is when the data needs to be translated in some manner before the application can use it. For example, if the data is compressed, the application must uncompress it before this data can be sent to the database. The application might even have a number of different translation functions that you can choose at run time; it simply sets the appropriate function pointer to the desired translation function.

To have Informix® ESQL/C use your own C functions to define the TEXT or BYTE data location, set the loc_loctype field of the locator structure to LOCUSER as follows:
EXEC SQL BEGIN DECLARE SECTION;
    ifx_loc_t my_simple_lo;
EXEC SQL END DECLARE SECTION;


my_simple_lo.loc_loctype = LOCUSER; 
With a user-defined simple-large-object location, a locator structure uses the fields that the following table summarizes.
Table 1. Fields in the locator structure used to create user-defined location functions
Field Data type Description
loc_open mint (*)() A pointer to a user-defined open function that returns an integer value.
loc_read mint (*)() A pointer to a user-defined read function that returns an integer value.
loc_write mint (*)() A pointer to a user-defined write function that returns an integer value.
loc_close mint (*)() A pointer to a user-defined close function that returns an integer value.
loc_user_env char * The address of the buffer to hold data that a user-defined location function needs. For example, you can set loc_user_env to the address of a common work area.
loc_xfercount 4-byte integer The number of bytes that the last transfer operation for the simple large object transferred.

With a user-defined simple-large-object location, a locator structure can use either the lc_mem structure or the lc_file structure of the lc_union structure. Fields in lc_union.lc_mem structure used for simple large objects located in memory and Fields in lc_union.lc_file structure used for simple large objects located in files summarize fields of the lc_union.lc_mem structure and lc_union.lc_file structure.