Module: DB Interface Module Group: Bulk Classes
Does not inherit
#include <rw/db/bkins.h> #include <rw/db/table.h> RWDBBulkInserter ins = table.bulkInserter(connection);
Like RWDBInserter, RWDBBulkInserter is a class designed to insert data into database tables. The main difference between RWDBBulkInserter and RWDBInserter is that arrays of values are shifted into RWDBBulkInserter for each column in the table, while scalar values are shifted into RWDBInserter. These arrays are passed by reference and need to stay in scope for the duration of the inserter. The class RWDBTBuffer<T> is used for inserting all types of data, including numeric types, dates, strings and binary data.
RWDBBulkInserter is designed around the Interface/Implementation paradigm. An RWDBBulkInserter instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation. An RWDBBulkInserter implementation is a base class from which a family of database-specific implementations is derived.
The following example uses an RWDBBulkInserter to insert an array of strings and integers into a table.
// Define the arrays that will hold the data to be // inserted. const int length = 10; RWDBTBuffer< RWCString > stringBuffer(length); RWDBTBuffer< int > intBuffer(length); // Populate the arrays using a user-defined function. setValues(stringBuffer, intBuffer); // Define the inserter. RWDBBulkInserter ins = tab.bulkInserter(connection); // Shift the arrays into the inserter. ins << stringBuffer << intBuffer; // Insert up to length values at a time. RWDBResult result = ins.execute(length);
RWDBBulkInserter();
Default constructor. Creates an RWDBBulkInserter whose status is RWDBStatus::notInitialized. This constructor is provided as a convenience; for example, for declaring an array of RWDBBulkInserters. Usable RWDBBulkInserters are obtained from valid RWDBTables.
RWDBBulkInserter(const RWDBBulkInserter& ins);
Copy constructor. The created RWDBBulkInserter shares an implementation with ins.
RWDBBulkInserter& operator=(const RWDBBulkInserter& ins);
Assignment operator. Self shares an implementation with ins.
RWDBBulkInserter& operator[](size_t index);
Changes the current row position to index. If index is out of range, self's status is set to RWDBStatus::invalidPosition. Returns a reference to self.
RWDBBulkInserter& operator[](const RWCString& columnName);
Changes the current row position to columnName and sets the column list.
RWDBBulkInserter& operator[](const RWDBColumn& column);
Changes the current row position to column and sets the column list.
RWDBBulkInserter& 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.
operator<< is capable of taking RWDBTBuffer<T>.
NOTE -- Please use RWDBTBuffer<T> for binding data using above method.
RWDBBulkInserter& 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.
RWDBResult execute();
Causes each of the values associated with each of the arrays shifted into self to be inserted into the table associated with self. Returns an RWDBResult.
RWDBResult execute(size_t iters);
Causes the first iters values associated with each of the arrays shifted into self to be inserted into the table associated with self. Returns an RWDBResult.
bool isValid() const;
Returns true if self's status is RWDBStatus::ok, otherwise returns false.
RWDBStatus status() const;
Returns the status of self.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.