Library Version 12.1.6.0

DbStream::read()
Prev | Chapter 14. Binary Large Objects | Next

## DbStream::read()

    #include <db_cxx.h>

    int
    DbStream::read(Dbt *data, db_off_t offset, u_int32_t size,
                   u_int32_t flags);

The `DbStream::read()` method reads size bytes from the BLOB, starting at offset, into the DBT data.

The stream is created using Dbc::db_stream().

Unless otherwise specified, the `DbStream::read()` method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Parameters

#### data

The data parameter is the Dbt into which you want to place the data read using this method.

Note that the data DBT must be set with one of the following flags, or this method will return an error: DB_DBT_MALLOC, DB_DBT_REALLOC, DB_DBT_USERMEM, or DB_DBT_APPMALLOC.

#### offset

The offset parameter indicates the starting position, in bytes, from the beginning of the BLOB where you want the read to begin.

#### size

The size parameter indicates the number of bytes to read.

#### flags

The flags parameter must be set to 0.

### Errors

The `DbStream::read()` method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

#### DB_BUFFER_SMALL

The Dbt provided to this method was not configured appropriately, and so there is not enough space allocated for the bytes you are trying to read.

#### EINVAL

An invalid flag value or parameter was specified; or if the Dbt was configured with DB_DBT_PARTIAL.

### Class

DbStream

### See Also

BLOBs and Related Methods

Prev | Up | Next
DbStream::close() | Home | DbStream::size()