SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Reads result sets, represented as arrays of RWDBTBuffer or RWDBDateVector, that are associated with an RWDBTable or RWDBSelector. (For reading scalar values, use RWDBReader.) More...
#include <rw/db/bkread.h>
Public Member Functions | |
RWDBBulkReader () | |
RWDBBulkReader (const RWDBBulkReader &rdr) | |
int | cancel () |
bool | isValid () const |
size_t | operator() () |
RWDBBulkReader & | operator<< (RWDBAbstractBuffer &val) |
RWDBBulkReader & | operator<< (RWDBDateVector &dateVector) |
RWDBBulkReader & | operator= (const RWDBBulkReader &rdr) |
RWDBBulkReader & | operator[] (size_t index) |
size_t | position () const |
RWDBStatus | status () const |
Like RWDBReader, RWDBBulkReader is a class designed to read result sets associated with an RWDBTable or RWDBSelector. The main difference between RWDBBulkReader and RWDBReader is that arrays of values are shifted into the RWDBBulkReader for each column in the result set, while scalar values are shifted out of the RWDBReader. These arrays are passed by reference and need to stay in scope for the duration of the reader. The class RWDBTBuffer is used for reading all types of data, including numbers, dates, strings, and binary data.
RWDBBulkReader is designed around the Interface/Implementation paradigm. An RWDBBulkReader instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation. An RWDBBulkReader implementation is a base class from which a family of database-specific implementations is derived.
The following example uses an RWDBBulkReader to read a result set, where the first column is a date and the second column is an integer.
RWDBBulkReader::RWDBBulkReader | ( | ) |
Default constructor. Creates an RWDBBulkReader whose status is RWDBStatus::notInitialized. This constructor is provided as a convenience; for example, for declaring an array of RWDBBulkReader instances. Usable RWDBBulkReader objects are obtained from valid RWDBTable objects.
RWDBBulkReader::RWDBBulkReader | ( | const RWDBBulkReader & | rdr | ) |
Copy constructor. The created RWDBBulkReader shares an implementation with rdr.
int RWDBBulkReader::cancel | ( | ) |
Cancels any pending results associated with self. Subsequent calls to operator()() iterate over a fresh result set based on the current values of the set of bound variables associated with the selector that produced self.
bool RWDBBulkReader::isValid | ( | ) | const |
Returns true
if self's status is RWDBStatus::ok, otherwise false
.
size_t RWDBBulkReader::operator() | ( | ) |
Fetches into the internal array the next set of rows from the result set associated with self. Up to n
rows are fetched at a time, where n
is equal to the length of the shortest array being fetched. Returns the number of rows actually fetched. A return value of 0
indicates that there is no additional data to fetch.
RWDBBulkReader& RWDBBulkReader::operator<< | ( | RWDBAbstractBuffer & | val | ) |
Shifts in the val to be associated with the column at the current position. Increments the current position. Returns a reference to self.
This operator is capable of taking RWDBTBuffer.
RWDBBulkReader& RWDBBulkReader::operator<< | ( | RWDBDateVector & | dateVector | ) |
Shifts in the dateVector to be associated with the column at the current position. Increments the current position. Returns a reference to self.
RWDBBulkReader& RWDBBulkReader::operator= | ( | const RWDBBulkReader & | rdr | ) |
Assignment operator. Self shares an implementation with rdr.
RWDBBulkReader& RWDBBulkReader::operator[] | ( | size_t | index | ) |
Changes the current column position to index. If index is out of range, self's status is set to RWDBStatus::invalidPosition. Returns a reference to self.
size_t RWDBBulkReader::position | ( | ) | const |
RWDBStatus RWDBBulkReader::status | ( | ) | const |
Returns the status of self.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |