Library Version 18.1.40

Dbc::db_stream()
Prev | Chapter 14. External Files | Next

## Dbc::db_stream()

    #include <db_cxx.h>

    int
    Dbc::db_stream(DbStream **dbs, u_int32_t flags);

The `Dbc::db_stream()` method points to a key/value pair where the data item is an external file. Use the flags parameter to indicate whether the stream is to be opened for reading, or for reading and writing.

Once the stream is opened, you read it using DbStream::read() , and you write to it using DbStream::write() .

Close this stream using DbStream::close() .

If the data item is not an external file, this method returns an error.

Unless otherwise specified, the `Dbc::db_stream()` 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

#### dbs

The dbs parameter references memory into which is copied the newly opened stream.

#### flags

The flags parameter must be set by bitwise inclusively OR'ing together one or more of the following values:

- `DB_STREAM_READ`

  Indicates that the stream is to be opened for read-only access.

- `DB_STREAM_WRITE`

  Indicates that the stream is to be opened for read write access. The stream is sync'd to disc when the stream is closed.

- `DB_STREAM_SYNC_WRITE`

  Indicates that the stream is to be opened for read and write access. The stream is sync'd to disc after each write, instead of when the stream is closed.

### Errors

The `Dbc::db_stream()` 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:

#### EINVAL

If the data item is not an external file; or if an invalid flag or parameter is specified.

### Class

Dbc

### See Also

External Files and Related Methods

Prev | Up | Next
Db::set_ext_file_threshold() | Home | DbStream::close()