NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CBulkInsert Class Reference

Search Toolkit Book for CBulkInsert

Object used to perform bulk-inserting operations to database. More...

#include <dbapi/simple/sdbapi.hpp>

+ Collaboration diagram for CBulkInsert:

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...
 
CBulkInsertoperator= (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...
 
CBulkInsertoperator<< (const string &val)
 Put values of different type into bulk-insert row. More...
 
CBulkInsertoperator<< (const char *val)
 
CBulkInsertoperator<< (unsigned char val)
 
CBulkInsertoperator<< (short val)
 
CBulkInsertoperator<< (Int4 val)
 
CBulkInsertoperator<< (Int8 val)
 
CBulkInsertoperator<< (long val)
 
CBulkInsertoperator<< (float val)
 
CBulkInsertoperator<< (double val)
 
CBulkInsertoperator<< (bool val)
 
CBulkInsertoperator<< (const CTime &val)
 
CBulkInsertoperator<< (const TStringUCS2 &val)
 Special case to support inserting into NVARCHAR and NTEXT fields. More...
 
CBulkInsertoperator<< (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< CBulkInsertImplm_Impl
 Bulk-insert implementation object. More...
 

Friends

class CDatabase
 
CBulkInsertNullValue (CBulkInsert &bi)
 Manipulator putting null value into the bulk-insert row. More...
 
CBulkInsertEndRow (CBulkInsert &bi)
 Manipulator ending row in the bulk-insert object. More...
 

Detailed Description

Object used to perform bulk-inserting operations to database.

Definition at line 815 of file sdbapi.hpp.

Member Enumeration Documentation

◆ EHints

Type of hint that can be set for bulk insert.

Enumerator
eTabLock 
eCheckConstraints 
eFireTriggers 

Definition at line 832 of file sdbapi.hpp.

◆ EHintsWithValue

Type of hint that requires some value to be provided with it.

Enumerator
eRowsPerBatch 
eKilobytesPerBatch 

Definition at line 842 of file sdbapi.hpp.

Constructor & Destructor Documentation

◆ CBulkInsert() [1/3]

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::~CBulkInsert ( void  )

Definition at line 2376 of file sdbapi.cpp.

◆ CBulkInsert() [2/3]

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.

◆ CBulkInsert() [3/3]

CBulkInsert::CBulkInsert ( CDatabaseImpl db_impl,
const string table_name,
int  autoflush 
)
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.

Member Function Documentation

◆ AddHint() [1/2]

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.

◆ AddHint() [2/2]

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.

◆ AddOrderHint()

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

void CBulkInsert::Bind ( int  col,
ESDB_Type  type 
)

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().

◆ Complete()

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().

◆ operator<<() [1/13]

CBulkInsert & CBulkInsert::operator<< ( bool  val)

Definition at line 2504 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [2/13]

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().

◆ operator<<() [3/13]

CBulkInsert & CBulkInsert::operator<< ( const char *  val)

Definition at line 2442 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [4/13]

CBulkInsert & CBulkInsert::operator<< ( const CTime val)

Definition at line 2511 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [5/13]

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().

◆ operator<<() [6/13]

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().

◆ operator<<() [7/13]

CBulkInsert & CBulkInsert::operator<< ( double  val)

Definition at line 2497 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [8/13]

CBulkInsert & CBulkInsert::operator<< ( float  val)

Definition at line 2490 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [9/13]

CBulkInsert & CBulkInsert::operator<< ( Int4  val)

Definition at line 2463 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [10/13]

CBulkInsert & CBulkInsert::operator<< ( Int8  val)

Definition at line 2470 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [11/13]

CBulkInsert & CBulkInsert::operator<< ( long  val)

Definition at line 2478 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [12/13]

CBulkInsert & CBulkInsert::operator<< ( short  val)

Definition at line 2456 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator<<() [13/13]

CBulkInsert & CBulkInsert::operator<< ( unsigned char  val)

Definition at line 2449 of file sdbapi.cpp.

References m_Impl, val, and CBulkInsertImpl::WriteVal().

◆ operator=()

CBulkInsert & CBulkInsert::operator= ( const CBulkInsert bi)

Definition at line 2380 of file sdbapi.cpp.

References m_Impl.

◆ SetHints()

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().

Friends And Related Function Documentation

◆ CDatabase

friend class CDatabase
friend

Definition at line 891 of file sdbapi.hpp.

◆ EndRow

CBulkInsert& EndRow ( CBulkInsert bi)
friend

Manipulator ending row in the bulk-insert object.

Definition at line 2532 of file sdbapi.cpp.

◆ NullValue

CBulkInsert& NullValue ( CBulkInsert bi)
friend

Manipulator putting null value into the bulk-insert row.

Definition at line 2525 of file sdbapi.cpp.

Member Data Documentation

◆ m_Impl

CRef<CBulkInsertImpl> CBulkInsert::m_Impl
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().


The documentation for this class was generated from the following files:
Modified on Wed Sep 04 15:00:08 2024 by modify_doxy.py rev. 669887