NCBI C++ ToolKit
|
Search Toolkit Book for CBulkInsert
Object used to perform bulk-inserting operations to database. More...
#include <dbapi/simple/sdbapi.hpp>
Public Types | |
enum | EHints { eTabLock , eCheckConstraints , eFireTriggers } |
Type of hint that can be set for bulk insert. More... | |
enum | EHintsWithValue { eRowsPerBatch , eKilobytesPerBatch } |
Type of hint that requires some value to be provided with it. More... | |
Public Member Functions | |
CBulkInsert (void) | |
Empty constructor of bulk-insert object. More... | |
~CBulkInsert (void) | |
CBulkInsert (const CBulkInsert &bi) | |
Copying of bulk-insert object. More... | |
CBulkInsert & | operator= (const CBulkInsert &bi) |
void | AddHint (EHints hint) |
Add hint to the bulk insert. More... | |
void | AddHint (EHintsWithValue hint, unsigned int value) |
Add hint with value to the bulk insert. More... | |
void | AddOrderHint (CTempString columns) |
Add "ORDER" hint. More... | |
void | SetHints (CTempString hints) |
Set hints by one call. Resets everything that was set by Add*Hint(). More... | |
void | Bind (int col, ESDB_Type type) |
Bind column for bulk insert. More... | |
CBulkInsert & | operator<< (const string &val) |
Put values of different type into bulk-insert row. More... | |
CBulkInsert & | operator<< (const char *val) |
CBulkInsert & | operator<< (unsigned char val) |
CBulkInsert & | operator<< (short val) |
CBulkInsert & | operator<< (Int4 val) |
CBulkInsert & | operator<< (Int8 val) |
CBulkInsert & | operator<< (long val) |
CBulkInsert & | operator<< (float val) |
CBulkInsert & | operator<< (double val) |
CBulkInsert & | operator<< (bool val) |
CBulkInsert & | operator<< (const CTime &val) |
CBulkInsert & | operator<< (const TStringUCS2 &val) |
Special case to support inserting into NVARCHAR and NTEXT fields. More... | |
CBulkInsert & | operator<< (CBulkInsert &(*f)(CBulkInsert &)) |
Special case of putting NullValue or EndRow into the row. More... | |
void | Complete () |
Complete bulk insert. More... | |
Private Member Functions | |
CBulkInsert (CDatabaseImpl *db_impl, const string &table_name, int autoflush) | |
Create bulk-insert object for given database, table name and number of rows to write before auto-flush occurs. More... | |
Private Attributes | |
CRef< CBulkInsertImpl > | m_Impl |
Bulk-insert implementation object. More... | |
Friends | |
class | CDatabase |
CBulkInsert & | NullValue (CBulkInsert &bi) |
Manipulator putting null value into the bulk-insert row. More... | |
CBulkInsert & | EndRow (CBulkInsert &bi) |
Manipulator ending row in the bulk-insert object. More... | |
Object used to perform bulk-inserting operations to database.
Definition at line 815 of file sdbapi.hpp.
enum CBulkInsert::EHints |
Type of hint that can be set for bulk insert.
Enumerator | |
---|---|
eTabLock | |
eCheckConstraints | |
eFireTriggers |
Definition at line 832 of file sdbapi.hpp.
Type of hint that requires some value to be provided with it.
Enumerator | |
---|---|
eRowsPerBatch | |
eKilobytesPerBatch |
Definition at line 842 of file sdbapi.hpp.
CBulkInsert::CBulkInsert | ( | void | ) |
Empty constructor of bulk-insert object.
Object created this way cannot be used for anything except assigning from other bulk-insert object.
Definition at line 2362 of file sdbapi.cpp.
CBulkInsert::~CBulkInsert | ( | void | ) |
Definition at line 2376 of file sdbapi.cpp.
CBulkInsert::CBulkInsert | ( | const CBulkInsert & | bi | ) |
Copying of bulk-insert object.
Any copy will work with the same bulk-insert session on the server. So that Complete() call on any of the copies will end up this session and no insertion will be possible to make from other copies.
Definition at line 2372 of file sdbapi.cpp.
|
private |
Create bulk-insert object for given database, table name and number of rows to write before auto-flush occurs.
Definition at line 2365 of file sdbapi.cpp.
References m_Impl, CRef< C, Locker >::Reset(), and table_name.
void CBulkInsert::AddHint | ( | EHints | hint | ) |
Add hint to the bulk insert.
Resets everything that was set by SetHints().
Definition at line 2393 of file sdbapi.cpp.
References CBulkInsertImpl::AddHint(), m_Impl, s_ConvertHints(), and SDBAPI_CATCH_LOWLEVEL.
void CBulkInsert::AddHint | ( | EHintsWithValue | hint, |
unsigned int | value | ||
) |
Add hint with value to the bulk insert.
Value should not be equal to zero. Resets everything that was set by SetHints().
Definition at line 2402 of file sdbapi.cpp.
References CBulkInsertImpl::AddHint(), m_Impl, s_ConvertHints(), SDBAPI_CATCH_LOWLEVEL, and rapidjson::value.
void CBulkInsert::AddOrderHint | ( | CTempString | columns | ) |
Add "ORDER" hint.
Resets everything that was set by SetHints().
Definition at line 2411 of file sdbapi.cpp.
References CBulkInsertImpl::AddOrderHint(), columns, and m_Impl.
Bind column for bulk insert.
All columns are numbered starting with 1. Columns should be bound in strict order (1st column first, then 2nd, then 3rd etc) and no columns can be bound several times. Type given is data type which all values will be converted to and how data will be sent to the server.
Definition at line 2417 of file sdbapi.cpp.
References CBulkInsertImpl::Bind(), and m_Impl.
Referenced by CSdbapiTest::Run().
void CBulkInsert::Complete | ( | void | ) |
Complete bulk insert.
Nothing can be inserted after call to this method.
Definition at line 2423 of file sdbapi.cpp.
References CBulkInsertImpl::Complete(), and m_Impl.
Referenced by CSdbapiTest::Run().
CBulkInsert & CBulkInsert::operator<< | ( | bool | val | ) |
Definition at line 2504 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | CBulkInsert &(*)(CBulkInsert &) | f | ) |
Special case of putting NullValue or EndRow into the row.
Definition at line 2518 of file sdbapi.cpp.
References f().
CBulkInsert & CBulkInsert::operator<< | ( | const char * | val | ) |
Definition at line 2442 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | const CTime & | val | ) |
Definition at line 2511 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | const string & | val | ) |
Put values of different type into bulk-insert row.
Automatic conversion is made to the bound type if possible. If conversion is not possible then exception is thrown. Number of values put into the row should be exactly the same as number of columns bound with calls to Bind().
Definition at line 2428 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | const TStringUCS2 & | val | ) |
Special case to support inserting into NVARCHAR and NTEXT fields.
Definition at line 2435 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | double | val | ) |
Definition at line 2497 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | float | val | ) |
Definition at line 2490 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | Int4 | val | ) |
Definition at line 2463 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | Int8 | val | ) |
Definition at line 2470 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | long | val | ) |
Definition at line 2478 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | short | val | ) |
Definition at line 2456 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator<< | ( | unsigned char | val | ) |
Definition at line 2449 of file sdbapi.cpp.
References m_Impl, val, and CBulkInsertImpl::WriteVal().
CBulkInsert & CBulkInsert::operator= | ( | const CBulkInsert & | bi | ) |
Definition at line 2380 of file sdbapi.cpp.
References m_Impl.
void CBulkInsert::SetHints | ( | CTempString | hints | ) |
Set hints by one call. Resets everything that was set by Add*Hint().
Definition at line 2387 of file sdbapi.cpp.
References m_Impl, and CBulkInsertImpl::SetHints().
|
friend |
Definition at line 891 of file sdbapi.hpp.
|
friend |
Manipulator ending row in the bulk-insert object.
Definition at line 2532 of file sdbapi.cpp.
|
friend |
Manipulator putting null value into the bulk-insert row.
Definition at line 2525 of file sdbapi.cpp.
|
private |
Bulk-insert implementation object.
Definition at line 903 of file sdbapi.hpp.
Referenced by AddHint(), AddOrderHint(), Bind(), CBulkInsert(), Complete(), EndRow(), NullValue(), operator<<(), operator=(), and SetHints().