ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Write Accesses → 

INSERT, UPDATE, MODIFY dbtab - LOB Handles

In the INSERT, UPDATE, or MODIFY statements, LOB handles can be created as writer streams and specified as locators.

Prerequisites

An LOB in a row to be inserted or changed can be supplied from an LOB handle component of a work area or an individual reference variable for an LOB handle (at UPDATE with SET). The static type of each LOB handle component must be one of the following system classes for streaming or locators:

The stream type or locator type must match the data type of the LOBs.

Rules

Unlike for read accesses, the behavior is not the same for streams and locators.

Changing Accesses Using Writer Streams

If, for a changing access, an LOB is linked to a reference variable of the type CL_ABAP_DB_C_WRITER or CL_ABAP_DB_X_WRITER, a corresponding writer stream is usually created and the reference variable points to the object after execution. The LOB to be changed can be edited using the methods of the writer stream. When connecting an LOB to a writer stream which is referenced by an LOB handle component from the source work area, the following various platform-dependent behavior may occur:

A writer stream created in this way exists until it is explicitly closed using its method CLOSE from the IF_ABAP_CLOSE_RESOURCE interface. As long as a writer stream for an Open SQL statement is still open, the corresponding database operation is not finished. The state of the Open SQL statement is described using an object of the CL_ABAP_SQL_STATEMENT_HANDLE class, for which the GET_STATEMENT_HANDLE method returns a reference for every writer stream.

When using writer streams, an unhandleable exception is raised in the following cases:

Notes

Changing Accesses Using Locators.

If, in a change access, an LOB is associated with a reference variable of type CL_ABAP_DB_C_LOCATOR or CL_ABAP_DB_X_LOCATOR, then this variable must point to an appropriate locator, created in a statement SELECT for a LOB in a different database table or the same table. If the statement can be executed (sy-subrc is 0), the LOB to be changed is replaced directly in the database system using the complete LOB of the locator.

Restrictions

The following restrictions apply:

Note

Always close a LOB handle as soon as possible using its method CLOSE. Also refer to Streaming and Locators.

Examples