Example: Using a locator to work with a CLOB value

Suppose that you want your application program to retrieve a locator for a character large object (CLOB) value and then use the locator to extract data from the CLOB value.

Using this method, the program allocates only enough storage for one piece of CLOB data (the size is determined by the program). In addition, the program needs to issue only one fetch call using the cursor.

How the example LOBLOC program works

The example program has three sections that work with the CLOB locator variables:

  1. Declare host variables. CLOB locator host variables are declared.
  2. Fetch the CLOB value into the locator host variable. A CURSOR and FETCH routine is used to obtain the location of a CLOB field in the database to a locator host variable.
  3. Free the CLOB locators. The CLOB locators used in this example are freed, releasing the locators from their previously associated values.