ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Streaming and Locators → ABAP SQL - Examples of LOB Handles
Locator, copy column
The example demonstrates how column content can be copied using locators.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA:
source TYPE c LENGTH 255
VALUE '/SAP/PUBLIC/BC/ABAP/mime_demo/ABAP_Docu_Logo.gif',
target TYPE c LENGTH 255
VALUE 'picture_copy'.
DATA wa TYPE demo_blob_table LOCATOR FOR ALL COLUMNS.
cl_demo_input=>add_field( CHANGING field = source ).
cl_demo_input=>request( CHANGING field = target ).
SELECT SINGLE picture
FROM demo_blob_table
WHERE name = @source
INTO @wa-picture.
IF sy-subrc <> 0.
cl_demo_output=>display(
'Nothing found, run DEMO_DB_WRITER first!' ).
RETURN.
ENDIF.
wa-name = target.
INSERT demo_blob_table FROM @wa.
IF sy-subrc = 0.
cl_demo_output=>display(
'You can run DEMO_DB_READER with new name now' ).
ELSE.
cl_demo_output=>display(
'Target already exists' ).
ENDIF.
wa-picture->close( ).
Description
The method main
derives an
LOB handle structure from the structure of the database table DEMO_BLOB_TABLE, where the component PICTURE is declared as an
LOB handle component for a locator. This locator is then
created in a SELECT
statement.
A new value is then assigned to the key field of the LOB handle structure and the LOB handle structure
is used as a work area in an INSERT
statement. In this way, the content of
the column to which the locator is connected is copied to the corresponding column of the new row without the content having to be transported to the ABAP program.
If data previously written in the executable writer stream example is read, this is the data of a figure in the GIF format. By specifying the new name, the copied figure can be displayed using theexample for reader streams.