IDatabaseBulkInserter Class
(CDP2SQL::IDatabaseBulkInserter)Abstract interface for batch inserting rows into a database table. More...
| Header: | #include <IDatabaseBulkInserter> |
Public Types
| enum | TypeHint { UNSPECIFIED, BLOB } |
Public Functions
| virtual | ~IDatabaseBulkInserter() |
| virtual void | AddRow(const std::vector<Utils::Variant> &values) = 0 |
| virtual void | Cancel() = 0 |
| virtual void | Commit() = 0 |
| virtual void | SetColumnTypeHint(int column, int type) = 0 |
Detailed Description
Abstract interface for batch inserting rows into a database table.
This interface is created by IDatabaseConnection::CreateBulkInserter when the backend supports an optimized bulk insert path (e.g. COPY FROM for PostgreSQL). It provides a generic row-oriented API:
- AddRow - supply one row of values in column order.
- Commit - finalize the current batch, flushing all pending rows.
- Cancel - abort the current batch.
The object must be reusable: after Commit or Cancel, it must be possible to start a new batch by calling AddRow again.
Member Type Documentation
enum IDatabaseBulkInserter::TypeHint
Optional per-column type hints for bulk insert implementations.
| Constant | Value | Description |
|---|---|---|
CDP2SQL::IDatabaseBulkInserter::UNSPECIFIED | 0 | No explicit hint; the driver may infer the type from the provided Utils::Variant values. |
CDP2SQL::IDatabaseBulkInserter::BLOB | 1 | Column contains binary/blob data. |
Backend-specific/custom hints may use integer values greater than 100.
Member Function Documentation
[virtual] IDatabaseBulkInserter::~IDatabaseBulkInserter()
Destroys the instance of IDatabaseBulkInserter. The destructor is virtual.
[pure virtual] void IDatabaseBulkInserter::AddRow(const std::vector<Utils::Variant> &values)
Adds a single row to the current batch. The number of values must match the number of columns passed when creating the inserter.
A Utils::Variant with type Utils::eUNDEFINED (or !isValid()) is treated as SQL NULL.
Throws CDP2SQL::SQLException on errors (e.g. mismatched row size, conversion errors, driver errors).
[pure virtual] void IDatabaseBulkInserter::Cancel()
Aborts and discards the current batch.
This function should not throw.
After Cancel returns, the inserter must be ready to accept a new batch via AddRow.
[pure virtual] void IDatabaseBulkInserter::Commit()
Finalizes and flushes the current batch.
After Commit returns, the inserter must be ready to accept a new batch via AddRow.
[pure virtual] void IDatabaseBulkInserter::SetColumnTypeHint(int column, int type)
Set a per-column type hint.
The column is the 0-based column index within the columns list used to create the inserter.
The type is an implementation-defined integer value; callers should use values from CDP2SQL::IDatabaseBulkInserter::TypeHint for portable hints.
Backend-specific/custom hints may use integer values greater than 100.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.