1.4 LOB Locator and LOB Value

A LOB instance has a locator and a value. A LOB locator is a reference, or a pointer, to where the LOB value is physically stored. The LOB value is the data stored in the LOB.

A LOB locator can be assigned to any LOB instance of the same type, such as BLOB, CLOB, NCLOB, or BFILE. When you use a LOB in an operation such as passing a LOB as a parameter, you are actually passing a LOB locator. For the most part, you can work with a LOB instance in your application without being concerned with the semantics of LOB locators. There is no requirement to dereference LOB locators, as is required with pointers in some programming languages.

There are two different techniques to access and modify LOBs:

1.4.1 Using LOBs Without Locators

LOBs can be used in many operations similar to how VARCHAR2 or RAW data types are used. Such LOB operations can be performed without the use of LOB locators.

LOB operations that are similar to VARCHAR2 and RAW types include:
  • SQL and PLSQL built-in functions and implicit assignments
  • Data interface on LOBs that enables you to insert or select entire LOB data in a LOB column without using a LOB locator as follows:
    • Use a bind variable associated with a LOB column to insert character data into a CLOB, or RAW data into a BLOB. For example, in PLSQL you can insert a VARCHAR2 buffer into a CLOB column, and in OCI you can bind a buffer of type SQLT_CHAR to a CLOB column.
    • Define an output buffer in your application that holds character data selected from a CLOB or RAW data selected from a BLOB. For example, in PLSQL you can select the CLOB output of a query into a VARCHAR2 buffer, and in OCI you can define a CLOB query result item to a buffer of type SQLT_CHAR.

1.4.2 Using LOBs with Locators

You can use the LOB locator to access and modify LOB values by passing the LOB locator to the LOB APIs supplied with the database. These operations support efficient piecewise read and write to LOBs.

You should use this mode if your application needs to perform random or piecewise read or write calls to LOBs, which means it needs to specify the offset or amount of the operation to read or write a part of the LOB value.