Locate simple large objects in memory

To have Informix® ESQL/C locate the TEXT or BYTE data in primary memory, set the loc_loctype field of the locator structure to LOCMEMORY as follows:
EXEC SQL BEGIN DECLARE SECTION;
    loc_t my_simple_lo;
EXEC SQL END DECLARE SECTION;


my_simole_lo.loc_loctype = LOCMEMORY; 
When you use memory as a simple-large-object location, a locator structure uses the lc_mem structure of the lc_union structure. The following table summarizes the lc_union.lc_mem fields.
Table 1. Fields in lc_union.lc_mem structure used for simple large objects located in memory
Field Data type Description
lc_bufsize 4-byte integer The size, in bytes, of the buffer to which the lc_buffer field points.
lc_buffer char * The address of the buffer to hold the simple large-object value. Your Informix® ESQL/C program must allocate the space for this buffer and store its address here in lc_buffer.
lc_currdata_p char * The address of the system buffer. This is an internal field and must not be modified by the Informix® ESQL/C program.
lc_mflags mint The flags to use when you allocate memory.
The locator.h file provides the following macro shortcuts to use when you access fields in lc_union.lc_mem:
#define loc_bufsize       lc_union.lc_mem.lc_bufsize
#define loc_buffer        lc_union.lc_mem.lc_buffer
#define loc_currdata_p    lc_union.lc_mem.lc_currdata_p
#define loc_mflags        lc_union.lc_mem.lc_mflags
Tip: It is recommended that you use these shortcut names when you access the locator structure. The shortcut names improve code readability and reduce coding errors. This publication uses these shortcut names when it refers to the lc_bufsize, lc_buffer, lc_currdata_p, and lc_mflags fields of the lc_union.lc_mem structure.
The demo directory contains the following two sample Informix® ESQL/C programs that demonstrate how to handle simple-large-object data located in memory:
  • The getcd_me.ec program selects a simple large object into memory.
  • The updcd_me.ec program inserts a simple large object from memory.
These programs assume the stores7 database as the default database for the simple-large-object data. The user can specify another database (on the default database server) as a command-line argument.
getcd_me mystores

The getcd_me and updcd_me programs are briefly explained in Select a simple large object into memory and Insert a simple large object from memory.