Open SQL - Locators
System Classes for Locators
The associated system classes for the two types of LOBs are:
- CL_ABAP_DB_C_LOCATOR for CLOBs.
- CL_ABAP_DB_X_LOCATOR for BLOBs.
Locators contain the following methods which are implemented as kernel methods. This means that access to LOBs is completed by the ABAP runtime environment.
Methods in Both Locator Types
- GET_LENGTH returns the length of the LOB that is connected to a locator.
- FIND searches from an offset for a sub-sequence of an LOB which is connected to a locator, and returns its position. The length of a character type sub-sequence which can be searched for using FIND is limited to 1333 characters in Unicode systems and to 2666 characters in non-Unicode systems. The length of a binary sub-sequence is always limited to 2666 bytes.
Methods from the IF_ABAP_CLOSE_RESOURCE interface:
- CLOSE closes the locator.
- IS_CLOSED returns "X", if the locator is closed.
Methods in Character-Like Locators
- GET_SUBSTRING returns the sub-sequence specified using offset and length, of a CLOB which is connected to a locator.
Methods in Binary Locators
- GET_BYTES returns the sub-sequence, specified using offset and length, of a BLOB which is connected to a locator.
Creating Locators for LOBs
A locator that is bound to an LOB, that is, an instance of the class CL_ABAP_DB_C_LOCATOR or CL_ABAP_DB_X_LOCATOR,
can only be created if, in the
clause of the
SELECT statement, an LOB from the result set is assigned to a reference variable for a locator.
SELECT - LOB Handles.
The creation of locators is not possible in changing Open SQL statements. However, locators which were created in a read statement can be used to make changes.
Due to high resource consumption, locators must always be closed as soon as possible using their CLOSE
method. Especially when creating locators in
SELECT loops, consider that
locators are not closed implicitly using
ENDSELECT, unlike read streams, and must be closed explicitly. Furthermore, locators are closed implicitly at the end of a database LUW.