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:
- 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. - 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.
Parent topic: Introduction to Large Objects and SecureFiles
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.
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
, orRAW
data into aBLOB
. For example, in PLSQL you can insert aVARCHAR2
buffer into aCLOB
column, and in OCI you can bind a buffer of typeSQLT_CHAR
to aCLOB
column. - Define an output buffer in your application that holds
character data selected from a
CLOB
orRAW
data selected from aBLOB
. For example, in PLSQL you can select theCLOB
output of a query into aVARCHAR2
buffer, and in OCI you can define aCLOB
query result item to a buffer of typeSQLT_CHAR
.See Also:
Data Interface for LOBs
- Use a bind variable associated with a LOB column to
insert character data into a
Parent topic: LOB Locator and LOB Value
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.
See Also:
Locator Interface for LOBsParent topic: LOB Locator and LOB Value