#include <db.h> int DB_STREAM->write(DB_STREAM *dbs, DBT *data, db_off_t offset, u_int32_t flags);
The DB_STREAM->write()
method writes data
to an existing BLOB object in the database. This method writes
data contained in the DBT
data to the BLOB stream. Data is
written into the stream starting at the position indicated by
offset. The amount of data
written is determined by the size
field in the
DBT.
If this method writes data in the middle of the BLOB, it will overwrite existing data, instead of shifting it. If this method writes data to the end of the BLOB, the data is appended to the existing BLOB. You can determine how large a BLOB is using DB_STREAM->size().
To open a stream, use DBC->db_stream().
Unless otherwise specified, the
DB_STREAM->write()
method returns a non-zero error value on failure and 0 on success.
The data parameter is
the DBT containing the
data to be written to the BLOB. The amount of data to be
written is determined by the DBT's
size
field.
The offset parameter identifies the position in the BLOB where the write operation will begin.
The flags parameter must be set to 0 or the following value:
A sync to disk operation is performed on the stream at the end of the write operation. By default, the sync is performed only when the stream is closed using DB_STREAM->close(). Note that this flag can also be specified when the stream is created using DBC->db_stream(), in which case the sync behavior becomes the default behavior for this stream instance.
The DB_STREAM->write()
method may fail and return one of the following non-zero errors:
An invalid flag value or parameter was specified; or if the stream is read-only; or if the input DBT was configured with DB_DBT_PARTIAL.