ARTICLE
Open SQL - Locators
Open SQL supports locators for
LOB s in database tables.
System Classes for Locators
The associated system classes for the
two types of LOB s are:
CL_ABAP_DB_C_LOCATOR for
CLOB s .
CL_ABAP_DB_X_LOCATOR for
BLOB s .
The instances of the classes above belong to the
LOB handle s and implement the
corresponding interfaces . Usage in Open
SQL involves reference variables which point to the relevant LOB
handle s.
Important Methods
Locators contain the following methods which are implemented as
kernel methods . This means that access
to LOB s 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 LOB s
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 INTO
clause of the SELECT statement, an
LOB from the result set is assigned to a reference variable for a
locator .
Refer to SELECT - LOB Handle
s .
Note
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.
Closing Locators
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 .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved