ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP - Database Accesses → Open SQL → Open SQL - Streaming and Locators → Open SQL - Examples forLOB Handles
Read Stream, Read Out Database Table
The example demonstrates how data can be read out of a database table using a read stream.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA reader TYPE REF TO cl_abap_db_x_reader.
SELECT SINGLE picture
FROM demo_blob_table
INTO reader
WHERE name = name.
IF sy-subrc <> 0.
MESSAGE 'Nothing found, run DEMO_DB_WRITER first!'
TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
WHILE reader->data_available( ) = 'X'.
APPEND reader->read( 1022 ) TO pict.
ENDWHILE.
reader->close( ).
show_picture( ).
Description
In the method main
, a reference variable reader
is declared for a read stream. This read stream is then created in a SELECT
statement
.
The internal table pict
is then filled sequentially with binary data from the row found. If you are accessing data which was previously written in the
example for write streams, this is the data of a figure in the GIF format.
The show_picture
auxiliary method displays the figure in an HTML Browser.