The user-defined close function

To define how to perform clean-up tasks for the user-defined location, you create a C function called a user-defined close function.

When a transfer to or from the database server is complete, Informix® ESQL/C calls the close function that the loc_close field of the locator structure supplies. Cleanup tasks include closing files or deallocating memory that the user-defined location uses.

This function must receive one argument: the address of the locator structure, ifx_loc_t *loc_struc, where loc_struc is a locator structure that your user-defined close function uses. The user-defined close function must return the success code for the close operation as follows:
0
The cleanup was successful.
-1
The cleanup failed. This return code generates a loc_status (and SQLCODE) error of -453.
The following figure shows a skeleton function of a user-defined close function.
Figure 1. A sample user-defined close function
close_simple_lo (adloc)
ifx_loc_t    *adloc;
{
   adloc->loc_status = 0;
   if (adloc->loc_oflags & LOC_WONLY) /* if fetching */
      {
      adloc->loc_indicator = 0; /* clear indicator */
      adloc->loc_size = adloc->loc_xfercount;
      }
   return(0);
}