Home | Previous Page | Next Page   Data Manipulation > Using Smart Large Objects > Storing a Smart Large Object in a Database >

Access to a Smart Large Object

The DataBlade API provides the smart-large-object interface for access to smart large objects. This interface contains a set of functions and data types to provide access to smart large objects. (For more information, see Using the Smart-Large-Object Interface.) The smart-large-object interface provides access to the smart large object through its LO handle, as follows:

Selecting a Smart Large Object

A SELECT statement on a CLOB, BLOB, or opaque-type column retrieves an LO handle for a smart large object. It does not retrieve the actual data for the smart large object because this data resides in an sbspace.

To select a smart large object
  1. Use a SELECT statement to retrieve the LO handle from the CLOB, BLOB, or opaque-type column.

    The LO handle identifies the location of the smart large object on disk.

  2. Read the smart-large-object data from the sbspace of the smart large object.

    The LO handle identifies the smart large object to open. Once you open the smart large object, you obtain an LO file descriptor, which you can use to read data from the sbspace of the smart large object.

Storing a Smart Large Object

Because a smart large object can be quite large, it is not practical to store it directly in the database table. Instead, the INSERT and UPDATE statements store the LO handle of the smart large object in the CLOB, BLOB, or opaque-type column. The data of the smart large object resides in an sbspace.

To save a smart large object in a CLOB, BLOB, or opaque-type column
  1. For a new smart large object, ensure that the smart large object has an sbspace specified for its data.

    For most smart large objects, the sbspace name is the only storage characteristic that you need to specify. The smart-large-object optimizer can calculate values for all other storage characteristics. You can set particular storage characteristics to override these calculated values. However, most applications do not need to set storage characteristics at this level of detail. For more information, see Obtaining Storage Characteristics.

  2. Create a new LO handle for the smart large object and open the smart large object.

    When you create a smart large object, you obtain an LO handle and an LO file descriptor for the new smart large object.

  3. Write the smart-large-object data to the sbspace of the smart large object.

    Use the LO file descriptor to identify the smart large object whose data you want to write to the sbspace.

  4. Use the INSERT or UPDATE statement to store the LO handle into the CLOB, BLOB, or opaque-type column.

    The LO handle for the smart large object identifies the location of the smart large object on disk. Once you have written the data to the smart large object, provide its LO handle to the INSERT or UPDATE statement to save it in the database. The smart-large-object data remains in the sbspace.

Important:
The sbspace for the smart large object must exist before the INSERT statement executes.

When you store an LO handle in the database, the database server can ensure that the smart large objects are only freed when no more database columns reference them. For more information, see Deleting a Smart Large Object. For information on how to insert a smart large object from within a DataBlade API module, see Creating a Smart Large Object.

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