Home | Previous Page | Next Page   Data Manipulation > Using Smart Large Objects > Accessing a Smart Large Object >

Selecting the LO Handle

The SELECT statement can select an LO handle of a smart large object from a CLOB, BLOB, or opaque-type column. Because the desired result of a query is usually the contents of an object, not just its LO handle, the DataBlade API module must then use the LO handle that the mi_value( ) or mi_value_by_name( ) function returns to access the smart-large-object data in its sbspace.

To select a smart large object from the database
  1. Execute the SELECT statement with a DataBlade API statement-execution function such as mi_exec( ) or mi_exec_prepared_statement( ).
  2. Obtain the column value that the mi_value( ) or mi_value_by_name( ) function passes back in the MI_DATUM structure as appropriate for the control mode of the query:
    • For binary representation, the MI_DATUM structure contains a pointer to an LO handle.
    • For text representation, the MI_DATUM structure contains the hexadecimal dump of an LO handle. To access the smart-large-object data, you must convert the LO handle to its binary representation with mi_lo_from_string( ).

    For more information, see Binary and Text Representations of an LO Handle.

  3. Optionally, ensure that the LO handle is valid with mi_lo_validate( ).

For more information on how to select smart large objects, see Accessing Smart Large Objects.

Validating an LO Handle

An LO handle is valid when it correctly identifies the location of a smart large object in an sbspace. An LO handle might be invalid for either of the following reasons:

Use the mi_lo_validate( ) function to check whether an LO handle is valid. If mi_lo_validate( ) returns a positive integer, the LO handle is invalid. You can mark this LO handle as invalid with the mi_lo_invalidate( ) function. The following code fragment checks whether the LO handle that LO_hdl references is valid:

if ( mi_lo_validate(conn, LO_hdl) > 0 )
   mi_lo_invalidate(conn, LO_hdl);

You can use the mi_lo_validate( ) function in the support function of an opaque data type that contains smart large objects. In the lohandles( ) support function, this function can determine unambiguously which LO handles are valid for the given instance of the opaque type.

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