Home | Previous Page | Next Page   Descriptor Function Reference > Accessor Functions >

mi_tab_setuserdata()

The mi_tab_setuserdata() function stores a pointer to user data in the table descriptor.

Syntax

void mi_tab_setuserdata(MI_AM_TABLE_DESC *tableDesc,
   void *userdata)
tableDesc
points to the table descriptor.
user_data
points to a data structure that the access method creates.

Usage

The access method stores state information from one purpose function so that another purpose function can use it.

To save table-state information as user data
  1. Call the appropriate DataBlade API memory-management function to allocate PER_STMT_EXEC or PER_STMT_PREP memory for the user-data structure.
  2. Populate the user-data structure with the state information.
  3. Call the mi_tab_setuserdata() function to store the pointer that the memory-allocation function returns in the table descriptor.

    Pass the pointer as the user_data argument.

Typically, an access method performs the preceding procedure in the am_open purpose function and deallocates the user-data memory in the am_close purpose function. To have the table descriptor retain the pointer to the user data as long as the table remains open, specify a memory duration of PER_STMT_EXEC or PER_STMT_PREP as Memory-Duration Options and Persistent User Data describe.

To retrieve the pointer from the table descriptor to access the table-state user data, call the mi_tab_userdata() function in any purpose function between am_open and am_close.

Return Values

None

Related Topics

See the descriptions of:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]