rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWDBBulkInserter Class Reference
[Bulk Operations]

Used to insert an RWDBTBuffer array into a database table. (To insert scalar values, use RWDBInserter.). More...

#include <rw/db/bkins.h>

List of all members.

Public Member Functions

 RWDBBulkInserter ()
 RWDBBulkInserter (const RWDBBulkInserter &ins)
RWDBBulkInserteroperator= (const RWDBBulkInserter &ins)
RWDBResult execute ()
RWDBResult execute (size_t iters)
bool isValid () const
RWDBStatus status () const
RWDBBulkInserteroperator[] (size_t index)
RWDBBulkInserteroperator[] (const RWCString &columnName)
RWDBBulkInserteroperator[] (const RWDBColumn &column)
RWDBBulkInserteroperator<< (const RWDBAbstractBuffer &val)
RWDBBulkInserteroperator<< (const RWDBDateVector &dateVector)

Detailed Description

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.

Synopsis

 #include <rw/db/bkins.h>
 #include <rw/db/table.h>

 RWDBBulkInserter ins = table.bulkInserter(connection);

Examples

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);

Constructor & Destructor Documentation

RWDBBulkInserter::RWDBBulkInserter (  ) 

Default constructor. Creates an RWDBBulkInserter whose status is RWDBStatus::notInitialized. This constructor is provided as a convenience; for example, to declare an array of RWDBBulkInserter instances. Usable RWDBBulkInserter objects are obtained from valid RWDBTable objects.

RWDBBulkInserter::RWDBBulkInserter ( const RWDBBulkInserter ins  ) 

Copy constructor. The created RWDBBulkInserter shares an implementation with ins.


Member Function Documentation

RWDBResult RWDBBulkInserter::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.

RWDBResult RWDBBulkInserter::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.

bool RWDBBulkInserter::isValid (  )  const

Returns true if self's status is RWDBStatus::ok, otherwise returns false.

RWDBBulkInserter& RWDBBulkInserter::operator<< ( const RWDBDateVector dateVector  ) 
Deprecated:
Please pass in RWDBTBuffer<RWDateTime> instead.

Shifts in the dateVector to be associated with the column at the current position. Increments the current position. Returns a reference to self.

RWDBBulkInserter& RWDBBulkInserter::operator<< ( const 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<T>.

RWDBBulkInserter& RWDBBulkInserter::operator= ( const RWDBBulkInserter ins  ) 

Assignment operator. Self shares an implementation with ins.

RWDBBulkInserter& RWDBBulkInserter::operator[] ( const RWDBColumn column  ) 

Changes the current row position to column and sets the column list.

RWDBBulkInserter& RWDBBulkInserter::operator[] ( const RWCString columnName  ) 

Changes the current row position to columnName and sets the column list.

RWDBBulkInserter& 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.

RWDBStatus RWDBBulkInserter::status (  )  const

Returns the status of self.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.